Skip to content

query! macro infers type as Option for primary key #3967

@imnyxz

Description

@imnyxz

I have found these related issues/pull requests

related to #1923

Description

Expected behavior: infer that primary keys can't be optional

Reproduction steps

using sqite driver given a sample table:

CREATE TABLE IF NOT EXISTS users (
  id            INTEGER PRIMARY KEY,
);

the following code: let row = query!("SELECT id FROM users") infers the type of the inner Record (after stripping away errors, etc.) as row.id being Option<i64>

SQLx version

0.8.6

Enabled SQLx features

"runtime-tokio", "sqlite"

Database server and version

sqlite

Operating system

macOS

Rust version

1.88

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions