Skip to content

Instantly share code, notes, and snippets.

@canadaduane
Created January 15, 2018 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save canadaduane/8629bc281336577ca99bb1ccdda4eb55 to your computer and use it in GitHub Desktop.
Save canadaduane/8629bc281336577ca99bb1ccdda4eb55 to your computer and use it in GitHub Desktop.
Can't compile diesel app--what am I missing?
error[E0277]: the trait bound `i64: diesel::deserialize::FromSql<diesel::sql_types::Nullable<diesel::sql_types::BigInt>, _>` is not satisfied
--> src/main.rs:32:10
|
32 | .load::<db::models::Device>(&connection)
| ^^^^ the trait `diesel::deserialize::FromSql<diesel::sql_types::Nullable<diesel::sql_types::BigInt>, _>` is not implemented for `i64`
|
= help: the following implementations were found:
<i64 as diesel::deserialize::FromSql<diesel::sql_types::BigInt, DB>>
@canadaduane
Copy link
Author

For future arrivals: I needed to use Option<i64> because my field was Nullable. Like this:

use super::schema::devices;
use diesel::sql_types::Nullable;

#[derive(Queryable)]
pub struct Device {
  pub device_id: i64,
  pub barcode: Option<i64>,
  pub device_type: i32,
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment