postgresql - Diesel(锈库)不允许我进行更新声明
问题描述
结构是
#[derive(Identifiable, Queryable, Debug)]
#[table_name = "users"]
pub struct QueryableUser {
pub id: i32,
pub username: String,
pub password: String,
pub sex: bool,
pub profile: Option<String>,
pub birth: chrono::NaiveDate,
}
当我尝试更新结构时
diesel::update(&queryable_user).set(...);
它给了我这个错误
error[E0277]: the trait bound `user::QueryableUser: diesel::Identifiable` is not satisfied
--> src\message_handler\set_profile.rs:36:13
|
36 | diesel::update(user).set(profile.eq(None));
| ^^^^^^^^^^^^^^ the trait `diesel::Identifiable` is not implemented for `user::QueryableUser`
|
= help: the following implementations were found:
<&'ident user::QueryableUser as diesel::Identifiable>
= note: required because of the requirements on the impl of `diesel::query_builder::IntoUpdateTarget` for `user::QueryableUser`
= note: required by `diesel::update`
这真的很令人困惑,因为我在我的结构中派生了 Identifiable
解决方案
我忘了借用用户diesel::update(user).set(profile.eq(None));
推荐阅读
- powershell - 如何过滤 EventLog 以每天获取一个日志 - PowerShell
- android - 使用 Android Camera2 为 Surfaces 配置不同的 FPS
- python - 在 apply 中访问 groupby 值
- vba - 当我使用 DoCmd.OpenForm 时运行时关闭
- node.js - 使用 node.js 脚本重命名文件名的一部分
- javascript - 从 SQL 中以 JSON 格式检索多个记录集
- domain-driven-design - 是否可以在构建单体应用时实施 Scrum?
- python-3.x - 如何将'符号添加到字符串
- android - 错误:Gradle 任务 assembleDebug 失败,退出代码为 1 - 在颤振项目中更改包名称后
- angular - 如何实现 Angular 路由动画?