我有 Diesel 生成的以下模式:
table! {
user (id) {
id -> Uuid,
name -> Text
}
和相关的模型
use diesel::{
self,
Queryable,
Insertable,
};
use diesel::prelude::*;
use diesel::sql_types::Uuid;
use super::schema::user;
#[derive(Queryable)]
pub struct User {
pub id: Uuid,
pub name: String,
}
impl User {
pub fn get(id: i32, connection: &PgConnection) -> Vec<User> {
user::table.load::<User>(connection).unwrap()
}
}
当我尝试编译它时出现错误,它说:
21 | user::table.load::<User>(connection).unwrap()
| ^^^^ the trait `diesel::Queryable<diesel::sql_types::Uuid, diesel::pg::Pg>` is not implemented for `diesel::sql_types::Uuid`
如果我尝试插入,我会得到一个类似的错误,说Expression
没有实现。
这可能是我的依赖项有问题,还是我可能忘记添加到模型中?
[dependencies]
rocket = "0.4.0-rc.1"
serde = "1.0"
serde_derive = "1.0"
serde_json = "1.0"
diesel = { version = "1.0.0", features = ["postgres", "uuid"] }
r2d2 = "*"
r2d2-diesel = "*"
[dependencies.rocket_contrib]
version = "0.4.0-rc.1"
default-features = false
features = ["json", "diesel_postgres_pool", "uuid"]