我试图在Postgres.中使用UUID作为我的主键
我得到了东京邮政的‘`FromSql<'>_ _is not implemented for_ _Uuid`_的特性.
首先,我尝试使用tokio-pg-mapper,但它也显示了相同的编译错误。
因此,我尝试了diff方法,并尝试实现From on Struct,以直接从Row隐藏它。
当我尝试实现From以将Row类型转换为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")
}
}
}在tokio中仍然具有“`FromSql<'>_ _is not implemented for_ _Uuid`_”的特性
我知道它要求我为
FromSql类型实现UUID。 但是我查看了tokio-postgres文档,发现它已经在那里实现了。
,我错过什么了吗?
uuid=0.8
tokio-postgres=0.7.2
发布于 2021-08-20 16:36:21
要激活UUID支持,我需要在我的Cargo.toml文件中声明它,它将开始使用tokio-pg-mapper和我的自定义解决方案。
tokio-postgres = {version="0.7.2", features=["with-uuid-0_8"]}https://stackoverflow.com/questions/68865111
复制相似问题