SQLite query macros don't reject INSERTs that omit NOT NULL columns without defaults
I maintainer di solito rispondono entro 4 giorni
Nessuno ha ancora preso questa issue.
- #4260 di @Zelys-DFKH — chiusa senza merge
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 38/100
Direzione di ricerca
The report is about compile-time sqlx::query! INSERT checking for SQLite: omitted NOT NULL columns without DEFAULT still compile and fail at runtime. Start from how SQLite describe currently exposes bind counts and result-column metadata but not write completeness for the target table. A closed unmerged PR (#4260) already exists, so read that thread and the 0.8.6 describe path before changing macros. Done means the given INSERT fails at compile time (or docs state the SQLite limit).
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Rust
- Stelle
- 17.5k
- Fork
- 1.7k
- Merge medio
- 1g 17h
- PR unite (30g)
- 7
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di transact-rs/sqlx
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
transact-rs/sqlx#4466 ·
I maintainer di solito rispondono entro 4 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
transact-rs/sqlx#4453 ·
I maintainer di solito rispondono entro 4 giorni
-
Postgres text arrays: a quoted "NULL" element is decoded as SQL NULLForse già presa @MinJaeRun l’ha presa 9 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
transact-rs/sqlx#4452 ·
I maintainer di solito rispondono entro 4 giorni
-
Fetch stream ends after first error using query macrosForse già presa @barry3406 l’ha presa 209 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
transact-rs/sqlx#4126 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
transact-rs/sqlx#3963 · 2 commenti ·
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di transact-rs/sqlx
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
gitbutlerapp/gitbutler#16982 ·
I maintainer di solito rispondono entro 1 giorno
-
priority: high status: new topic: ga4gh-sdk type: docs type: maintenance workload: minutes
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
C-bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
rust-lang/rust-clippy#17976 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
aaif-goose/goose#13327 ·
I maintainer di solito rispondono entro 1 giorno
-
llm translation
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno