Skip to content

Select of a hardcoded value returns Option<T> instead of just T #3428

Open
@Donkere-vader

Description

@Donkere-vader

Bug Description

When including hardcoded values in a SELECT statement, the value that is returned by sqlx is an Option<T> type.

For example;

let record = query!("SELECT true as value").fetch_one(conn).await?;

println!("{:?}", record.value);

results in;

Some(true)

While I would expect that this should not have to be an option, since it is guaranteed that the value is always present.

Minimal Reproduction

github repo

Info

  • SQLx version: 0.7.3
  • SQLx features enabled: postgres, runtime-tokio
  • Database server and version: (Running in docker:) PostgreSQL 16.1 (Debian 16.1-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
  • Operating system: Pop!_OS 22.04 LTS x86_64
  • rustc --version: 1.80.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions