I am trying to use UUID as my primary key in Postgres.
I am getting the trait FromSql<'_>
is not implemented for Uuid
in tokio-postgres.
First I try to use tokio-pg-mapper
but it is also showing the same compile error.
So, I try diff approach and try to implement the From on Struct to covert it directly from Row.
When I try to implements From
to convert the Row
type to my struct Shop
.
impl From<Row> for Shop {
fn from(row: Row) -> Self {
Self {
id: row.get("id"), // Id is UUID type
name: row.get("name"),
address: row.get("address")
}
}
}
Still getting the the trait FromSql<'_>
is not implemented for Uuid
in tokio-postgres
I know that it is asking me to implement the
FromSql
for theUUID
type.
But I looked into thetokio-postgres
docs and found that it is already implemented there.
Did I miss something ?
uuid=0.8
tokio-postgres=0.7.2
To activate the
UUID
support I need to declare it in myCargo.toml
file and it will start working withtokio-pg-mapper
and with my custom solution too.