FAQs - Deisel
Diesel is a Safe, Extensible ORM and Query Builder for Rust.
panicked at ‘called Result::unwrap()
on an Err
value: DeserializationError(UnexpectedNullError)’
Remember to make optional attribute adn column with Option
or Nullable
.
1 2 3 4 5 6 7 8 9 10 11
|
use uuid::Uuid;
#[derive(Queryable)] pub struct Post { pub id: i32,
- pub name: title, + pub name: Option<title>, }
|
1 2 3 4 5 6 7 8 9 10
|
table! { posts (id) { id -> Int4,
- name -> Varchar, + name -> Nullable(Varchar), } }
|
the trait Queryable<diesel::sql_types::Uuid, _>
is not implemented for uuid::Uuid
1 2 3 4 5 6 7 8 9 10
|
use uuid::Uuid;
#[derive(Queryable)] pub struct Post { pub id: Uuid,
pub name: title, }
|
1 2 3 4 5 6 7 8 9
|
table! { posts (id) { id -> Uuid,
name -> Varchar, } }
|
1 2 3 4 5 6 7
|
let connection = pool::establish_connection(); let results = posts .filter(title.eq("title")) .limit(5) .load::<Post>(&connection).unwrap();
|
See what’s in your Cargo.lock
file and look are uuid
package dependencies. Be sure they are using the same versions as uuid::Uuid
.
See postgresql - Cannot use UUID as a primary key: Uuid: diesel::Expression is not satisfied - Stack Overflow - https://stackoverflow.com/questions/60441600/cannot-use-uuid-as-a-primary-key-uuid-dieselexpression-is-not-satisfied to learn more.
References
[]