You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a type that wraps a primitive type that is annotated with #[sqlx(transparent)], much like this one in the test suite:
#[sqlx(transparent)]
struct Transparent(i32);
I have a &[Transparent] that I want to be able to use in a query like SELECT ... WHERE something IN ($1) with $1 bound to my slice of Transparent values.
I'm happy to submit that test case as a PR here if it's useful, but I wasn't sure enough that this use case is supported or that I'm doing what I'm supposed to be doing.
Thanks!
The text was updated successfully, but these errors were encountered:
This should work if you manually implement PgHasArrayType for Transparent in terms of i32s PgHasArrayType implementation.
I think there's another issue somewhere about basically the same thing for custom enum types. This is just a matter of nobody having put in the work to derive that trait yet.
What happened
I have a type that wraps a primitive type that is annotated with
#[sqlx(transparent)]
, much like this one in the test suite:I have a
&[Transparent]
that I want to be able to use in a query likeSELECT ... WHERE something IN ($1)
with$1
bound to my slice ofTransparent
values.Per the relevant FAQ entry, I tried:
but compiling this gives me the error
the trait `PgHasArrayType` is not implemented for `Transparent`
.Interestingly, if I map out the inner primitive value by doing something like:
then I don't get the compiler error.
I expected both of these to compile and function in the same way.
I've tried to make a minimal test case in this PR I made to my own fork so that I could demonstrate the compiler error happens in CI.
I'm happy to submit that test case as a PR here if it's useful, but I wasn't sure enough that this use case is supported or that I'm doing what I'm supposed to be doing.
Thanks!
The text was updated successfully, but these errors were encountered: