sqlx
sqlx copied to clipboard
Transparent type in a postgres `ANY` array, part two: with macros
I have found these related issues/pull requests
This is closely related to #1744 and it's solution #1748
Description
Basically the same thing as #1744 - make transparent types work with =ANY($2), but when using macros such as query!() and query_as!().
Right now, the macros error out:
error[E0308]: mismatched types
--> src/main.rs:11:9
|
11 | &values
| ^
| |
| expected `&[i32]`, found `&Vec<Transparent>`
| expected due to the type of this binding
|
= note: expected reference `&[i32]`
found reference `&Vec<Transparent>`
Reproduction steps
#[derive(sqlx::Type)]
#[sqlx(transparent)]
struct Transparent(i32);
fn main() {
let values = vec![Transparent(1), Transparent(2), Transparent(3)];
let _ = sqlx::query!(
r#"select 2 = ANY($1) as "b";"#,
&values
);
}
SQLx version
0.8.5
Enabled SQLx features
macros, postgres, runtime-tokio
Database server and version
Postgresql 17.4
Operating system
Arch Linux
Rust version
rustc 1.86.0 (05f9846f8 2025-03-31)