Skip to content

query_as! offline mode mismatched types expected struct X, found enum std::option::Option #1294

Open
@Tarang

Description

@Tarang

I noticed there i a similar issue #93

I am using the latest version of SQLx so I don't believe that issue was solved:

cargo sqlx --version
cargo-sqlx 0.5.5

To create the offline bundle and to recreate the error I run:

cargo sqlx prepare

I'm using the offline package with Postgres with the sqlx::query_as! macro and SQLx seems to think every column I have is nullable. So I get a generic error: mismatched types expected struct [i32, String, ..], found enum `std::option::Option

Its a bit random how it happens but its very frustrating when you make all your values Option< > eventually it realises and switches back to the opposite error where it expected Option but found an i32 or whatever the underlying struct was.

I have noticed the only pattern is when it has this error, every single struct is considered nullable vs incorrect ones singled out out of a list. So you either have SQLx think they are all nullable, or all of them are interpreted as the correct types.

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