Summary
With sqlx 0.8.6 and SQLite, a compile-time checked sqlx::query! INSERT that omits a NOT NULL / no-DEFAULT column still compiles. SQLite then rejects it only at runtime with NOT NULL constraint failed.
Reproduction
Repo: https://github.com/pascalporedda/sqlx-sqlite-not-null-repro
Schema:
CREATE TABLE session_group (
prop_a TEXT NOT NULL,
prop_b INTEGER NOT NULL,
prop_c TEXT NOT NULL
);
Query that compiles:
sqlx::query!(
r#"
INSERT INTO session_group (prop_a, prop_b)
VALUES (?, ?)
"#,
"test1",
123_i64,
)
Commands:
cargo check
cargo run --quiet
Observed runtime output:
full insert rows_affected = 1
partial insert runtime result = Err(
Database(
SqliteError {
code: 1299,
message: "NOT NULL constraint failed: session_group.prop_c",
},
),
)
persisted rows = [
"ok:1:present",
]
row count = 1
Expected
I expected the compile-time checked query macro to reject the INSERT because prop_c is omitted and is NOT NULL with no default.
Actual
The query compiles and only fails when executed.
Notes
I looked through the 0.8.6 sources locally and it appears the SQLite describe path provides bind parameter count and result-column metadata, but not target-table write completeness. If this is the intended limit of checking for SQLite, a documentation note would help. If not, this looks like a missing compile-time verification case.
Summary
With
sqlx 0.8.6and SQLite, a compile-time checkedsqlx::query!INSERTthat omits aNOT NULL/ no-DEFAULTcolumn still compiles. SQLite then rejects it only at runtime withNOT NULL constraint failed.Reproduction
Repo: https://github.com/pascalporedda/sqlx-sqlite-not-null-repro
Schema:
Query that compiles:
Commands:
Observed runtime output:
Expected
I expected the compile-time checked query macro to reject the
INSERTbecauseprop_cis omitted and isNOT NULLwith no default.Actual
The query compiles and only fails when executed.
Notes
I looked through the
0.8.6sources locally and it appears the SQLite describe path provides bind parameter count and result-column metadata, but not target-table write completeness. If this is the intended limit of checking for SQLite, a documentation note would help. If not, this looks like a missing compile-time verification case.