Open feymartynov opened 4 years ago
I'm having the same issue with:
#[derive(sqlx::Type)]
struct Contract {
id: i32,
user_id: i32,
order_id: i32,
tags: Vec<i32>,
}
Manually implementing decode using your strategy worked.
From what I noticed, it seems like the fact that composite types in Postgres do not have constraints means that all composite fields are automatically not null. And that means that the output type has to have all it's fields as Option<_>
.
This issue is a major blocker for me :(
Hope will be resolved soon.
I can't use a workaround impl Decode
since I am migrating from the 0.5.2 version to 0.6.2 and there is a lot of Option<T>
.
Is this still an issue in sqlx
0.8
? It seems fixed for me.
I can also confirm that it works on 0.8
.
Consider following types:
This fails to compile on 1.46 with:
I used cargo-expand to see what the derive macro expands to and
Decode
impl is like this:If I change
Foo: sqlx::decode::Decode<'r, sqlx::Postgres>,
toFoo: for<'q> sqlx::decode::Decode<'q, sqlx::Postgres>,
then it compiles well. Could this be a bug in thesqlx::Type
macro?