Diesel AsChangeset
Hello, I'm trying to use ArrayString with diesel and it fails to derive AsChangeset.
table! {
...
users (id) {
...
password_hash -> Varchar,
...
}
}
type PasswordHash = ArrayString<U64>;
#[derive(AsChangeset, Default, Debug)]
#[table_name = "users"]
pub struct UserSettingsChangeset {
pub password_hash: Option<PasswordHash>,
...
}
will lead to:
type mismatch resolving
<&arraystring::ArrayString<arraystring::typenum::UInt<arraystring::typenum::UInt<arraystring::typenum::UInt<arraystring::typenum::UInt<arraystring::typenum::UInt<arraystring::typenum::UInt<arraystring::typenum::UTerm, arraystring::typenum::B1>, arraystring::typenum::B1>, arraystring::typenum::B0>, arraystring::typenum::B0>, arraystring::typenum::B1>, arraystring::typenum::B0>> as diesel::Expression>::SqlType == diesel::sql_types::Nullable<diesel::sql_types::Text>- expected struct
diesel::sql_types::Text, found structdiesel::sql_types::Nullable - expected struct
diesel::sql_types::Textfound structdiesel::sql_types::Nullable<diesel::sql_types::Text>
It works with normal String...Option<T> in AsChangeset should just skip the field during update.
Any ideas what I'm doing wrong? Thank you
Hey, I'm unable to replicate this, I've added some tests to derive AsChangeset (and use it) and other missing derived traits and they all worked, if you want to check they are very messy, but are in src/integration.rs as unit tests.
If you can provide me a full example I may be able to fix it, the queries are probably the problem, not the deriving, since they may mess with other traits that ArrayString does not implement.
Diesel integration sadly is not that complete since it's very hard to properly integrate with it, since the devs aren't cooperative (because it would probably mean stabilizing a bunch of internals they don't want to stabilize).
That said, feel free to open new issues if you want more features, like that.
The reason for this i think is an unexhaustive implementation of the AsExpression trait (it seeds the base types, the nullables, the refs and all combinations between them). Diesel is excessively hard to debug on that front due to their trait salad. if you use diesel 2.0 you can try the code from #4, it should work as intended.