diff --git a/sqlite3.go b/sqlite3.go index f731d20..1cf9451 100644 --- a/sqlite3.go +++ b/sqlite3.go @@ -2062,9 +2062,8 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error { } dest[i] = t default: - dest[i] = []byte(s) + dest[i] = s } - } } return nil diff --git a/sqlite3_test.go b/sqlite3_test.go index 16bbb10..3ef8533 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.Fatalf("non-column string must return string but got %T", x) + } + 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 {