Skip to content
Discussion options

You must be logged in to vote

FWIW, the issue was that sqlx is depending on the NOT NULL flag in the column definition to infer Option<T>, which I had not included on the id column.

Resolved by changing:

CREATE TABLE waters (
    "id" INTEGER PRIMARY KEY,
    -- ...

... to ...

CREATE TABLE waters (
    "id" INTEGER PRIMARY KEY NOT NULL,
    -- ...

I found the issue by expanding the query_as! macro and discovering that sqlx was retrieving id as an Option<i64>.

Docs on option inference here: https://docs.rs/sqlx/latest/sqlx/macro.query.html#nullability-output-columns

For SQLite we perform a similar check to Postgres, looking for NOT NULL constraints on columns that come from tables. However, for SQLite we also can step…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jayhale
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant