From 5e7aedf6859708d1be6fe961dac3811e986fa4c3 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Mon, 11 Feb 2019 00:48:49 +0900 Subject: [PATCH] Add test --- sqlite3_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/sqlite3_test.go b/sqlite3_test.go index 16bbb10..28b3c96 100644 --- a/sqlite3_test.go +++ b/sqlite3_test.go @@ -1670,6 +1670,26 @@ func TestAuthorizer(t *testing.T) { } } +func TestNonColumnString(t *testing.T) { + db, err := sql.Open("sqlite3", ":memory:") + if err != nil { + t.Fatal(err) + } + defer db.Close() + + var x interface{} + if err := db.QueryRow("SELECT 'hello'").Scan(&x); err != nil { + t.Fatal(err) + } + s, ok := x.(string) + if !ok { + t.Fatal("non-column string must return string") + } + if s != "hello" { + t.Fatalf("non-column string must return %q but got %q", "hello", s) + } +} + func TestNilAndEmptyBytes(t *testing.T) { db, err := sql.Open("sqlite3", ":memory:") if err != nil {