No error on querry missing parameter. Is it by design? #7852
|
I moved a small project from sqlite3 driver to tursogo and encounter a strange error which I cannot reproduce anymore. However, I observed the following: Ln24 Is that by design? |
Replies: 1 comment 1 reply
|
Not really by design, more like two gaps lining up.
Prepare it yourself and the mismatch does surface: stmt, _ := db.Prepare("SELECT v FROM pair WHERE k=?")
rows, err := stmt.Query() // -> sql: expected 1 arguments, got 0that path goes through I'd file the direct- |
Not really by design, more like two gaps lining up.
db.Query()takes tursogo's fast path (the conn implementsQueryerContext), so database/sql never runs the arg-count check it'd normally do when it prepares the statement for you. Then tursogo's own bind step only validates the count when you pass at least one arg. Zero args skips that check, the?stays unbound, and an unbound parameter is NULL in SQLite. So your query is reallyWHERE k = NULL, which matches nothing (NULL never equals anything). No error, no rows.Prepare it yourself and the mismatch does surface:
that p…