Error caused by nullable varchar in diesel (database is PostgreSQL)

I'm using diesel.

I have this in my

table! {
    jobs (id) {
        id -> Int8,
        title -> Varchar,
        description -> Nullable<Varchar>,

and it is generating this error:

16 |     let results = jobs.load::<models::Job>(&connection)
   |                        ^^^^ the trait `diesel::deserialize::FromSql<diesel::sql_types::Nullable<diesel::sql_types::Text>, _>` is not implemented for `*const str`

I believe I can resolve this by changing "pub description: String" below:

pub struct Job {
    pub id: i64,
    pub title: String,
    pub description: String,

What can do to resolve my problem? Please help! Thanks!

Since it's nullable, description needs to be an Option<String>.

1 Like