sqlite3_column_blob() returns NULL for zero-length BLOB

This commit is contained in:
Akinori Hattori 2013-10-24 22:25:07 +09:00
parent 2a2faeaf38
commit ef9b514cad
1 changed files with 4 additions and 0 deletions

View File

@ -493,6 +493,10 @@ func (rc *SQLiteRows) Next(dest []driver.Value) error {
dest[i] = float64(C.sqlite3_column_double(rc.s.s, C.int(i))) dest[i] = float64(C.sqlite3_column_double(rc.s.s, C.int(i)))
case C.SQLITE_BLOB: case C.SQLITE_BLOB:
p := C.sqlite3_column_blob(rc.s.s, C.int(i)) p := C.sqlite3_column_blob(rc.s.s, C.int(i))
if p == nil {
dest[i] = nil
continue
}
n := int(C.sqlite3_column_bytes(rc.s.s, C.int(i))) n := int(C.sqlite3_column_bytes(rc.s.s, C.int(i)))
switch dest[i].(type) { switch dest[i].(type) {
case sql.RawBytes: case sql.RawBytes: