Skip to content

PostgreSQL querys don't support arrays containing nullable items #3775

@C0D3-M4513R

Description

@C0D3-M4513R

I have found these related issues/pull requests

I didn't find any

Description

The code provided in the reproduction steps fails to compile with:

error[E0308]: mismatched types
  --> src/main.rs:44:17
   |
44 | "#, &[1, 2, 3], &[Some(true), Some(false), None]).fetch_all(db).await;
   |                 ^
   |                 |
   |                 expected `&[bool]`, found `&[Option<bool>; 3]`
   |                 expected due to the type of this binding
   |
   = note: expected reference `&[bool]`
              found reference `&[std::option::Option<bool>; 3]`

Reproduction steps

let r = sqlx::query!(r#"
SELECT * FROM unnest(
    $1::bigint[],
    $2::bool[]
  ) AS t(
    user_id,
    admin
)
"#, &[1, 2, 3], &[Some(true), Some(false), None]).fetch_all(db).await;

SQLx version

0.8.3

Enabled SQLx features

["postgres", "runtime-tokio-rustls"]

Database server and version

postgres (PostgreSQL) 16.6

Operating system

Linux nixos-pc 6.12.16 #1-NixOS SMP PREEMPT_DYNAMIC Fri Feb 21 13:01:47 UTC 2025 x86_64 GNU/Linux

Rust version

rustc 1.85.0 (4d91de4e4 2025-02-17)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions