mirror of https://github.com/mattn/go-sqlite3.git
return io.EOF for empty Query statements
This commit is contained in:
parent
82bc911e85
commit
823d03f3f8
|
@ -2206,7 +2206,7 @@ func (rc *SQLiteRows) nextSyncLocked(dest []driver.Value) error {
|
|||
if rv != C.SQLITE_OK {
|
||||
return rc.s.c.lastError()
|
||||
}
|
||||
return nil
|
||||
return io.EOF
|
||||
}
|
||||
|
||||
rc.declTypes()
|
||||
|
|
|
@ -1997,6 +1997,34 @@ func TestNamedParam(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestEmptyQuery(t *testing.T) {
|
||||
db, err := sql.Open("sqlite3", ":memory:")
|
||||
if err != nil {
|
||||
t.Fatal("Failed to open database:", err)
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
queries := []string{
|
||||
"",
|
||||
";",
|
||||
" -- comment ",
|
||||
}
|
||||
|
||||
for _, q := range queries {
|
||||
t.Run(fmt.Sprintf("query:%q", q), func(t *testing.T) {
|
||||
rows, err := db.Query(q)
|
||||
if err != nil {
|
||||
t.Fatal("Failed to run empty query:", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
if rows.Next() != false {
|
||||
t.Fatal("Expected no rows")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
var customFunctionOnce sync.Once
|
||||
|
||||
func BenchmarkCustomFunctions(b *testing.B) {
|
||||
|
|
Loading…
Reference in New Issue