You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a query ends in a semicolon and there's another character after the semicolon, db.Query returns the following error.
bad parameter or other API misuse: not an error (21)
Here's a Go program that reproduces the issue.
package main
import (
"database/sql""fmt""log"
_ "github.com/glebarez/go-sqlite"
)
funcmain() {
db, err:=sql.Open("sqlite", ":memory:")
iferr!=nil {
log.Fatalln(err)
}
deferdb.Close()
if_, err:=db.Exec("create table foo(id integer primary key, bar text)"); err!=nil {
log.Println(err)
return
}
if_, err:=db.Exec("insert into foo (bar) values (?)", "bar"); err!=nil {
log.Println(err)
return
}
qs:= []string{
// bad parameter or other API misuse: not an error (21)"select id from foo limit 1; ",
"select id from foo limit 1;\n",
"select id from foo limit 1;\t",
" select id from foo limit 1; ",
// OK"select id from foo limit 1;",
" select bar from foo limit 1;",
"select bar from foo limit 1 ",
" select bar from foo limit 1",
}
for_, q:=rangeqs {
varbarstringiferr:=db.QueryRow(q).Scan(&bar); err!=nil {
fmt.Printf("FAIL: %q\n%s\n\n", q, err)
continue
}
fmt.Printf("OK: %q\n", q)
}
}
For github.com/glebarez/go-sqlite v1.21.2
Another SQLite library github.com/mattn/go-sqlite3 v1.14.17 does not exhibit this behavior.
The text was updated successfully, but these errors were encountered:
If a query ends in a semicolon and there's another character after the semicolon,
db.Query
returns the following error.Here's a Go program that reproduces the issue.
For
github.com/glebarez/go-sqlite v1.21.2
Another SQLite library
github.com/mattn/go-sqlite3 v1.14.17
does not exhibit this behavior.The text was updated successfully, but these errors were encountered: