Skip to content

Transparent type in a postgres ANY array, part two: with macros #3854

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jaskij opened this issue May 5, 2025 · 0 comments
Open

Transparent type in a postgres ANY array, part two: with macros #3854

jaskij opened this issue May 5, 2025 · 0 comments
Labels

Comments

@jaskij
Copy link

jaskij commented May 5, 2025

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)

@jaskij jaskij added the bug label May 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant