Merge pull request #692 from mattn/fix-688

Fix 688
This commit is contained in:
mattn 2019-02-11 11:20:17 +09:00 committed by GitHub
commit 58039ab376
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 2 deletions

View File

@ -2062,9 +2062,8 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
} }
dest[i] = t dest[i] = t
default: default:
dest[i] = []byte(s) dest[i] = s
} }
} }
} }
return nil return nil

View File

@ -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) { func TestNilAndEmptyBytes(t *testing.T) {
db, err := sql.Open("sqlite3", ":memory:") db, err := sql.Open("sqlite3", ":memory:")
if err != nil { if err != nil {