Quantcast
Channel: How to update an existing object with Diesel? "`T: Identifiable` is not satisfied" - Stack Overflow
Viewing all articles
Browse latest Browse all 2

How to update an existing object with Diesel? "`T: Identifiable` is not satisfied"

$
0
0

I have this struct:

#[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,}

When I try to update the struct like so:

diesel::update(&queryable_user).set(...);

it gives me this error:

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`

It's really confusing because I used #[derive(Identifiable)] on my struct.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>