Skip to content
Discussion options

You must be logged in to vote

Not really by design, more like two gaps lining up.

db.Query() takes tursogo's fast path (the conn implements QueryerContext), 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 really WHERE k = NULL, which matches nothing (NULL never equals anything). No error, no rows.

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 0

that p…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@J-Siu
Comment options

Answer selected by J-Siu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants