adwhit/diesel-derive-enum

FromSql is not implemented

Closed this issue · 0 comments

enum:

#[derive(Debug, PartialEq, DbEnum, Clone, Serialize, Deserialize)]
#[PgType = "permission"]
#[DieselType = "Permission"]
pub enum PermissionEnum {
    #[serde(rename = "admin")]
    #[db_rename = "mod"] // with or without both fails
    Admin,
}

struct:

#[derive(Queryable, Serialize, Identifiable)]
#[table_name = "user"]
pub struct User {
    pub id: Uuid,
    pub permissions: Vec<PermissionEnum>,
}

query:

dsl::user
    .find(user_id)
    .get_result::<R>(&conn)

error:

the trait `diesel::deserialize::FromSql<model::db_enum_impl_PermissionEnum::Permission, diesel::pg::Pg>` is not implemented for `model::PermissionEnum`

IMO, in addition to the current implement of FromSqlRow, FromSql should also be implemented.