Fix to pass TestNilAndEmptyBytes

This commit is contained in:
Greg Holt 2017-08-21 13:30:07 -07:00
parent d1772f0826
commit 85e456ef27
1 changed files with 3 additions and 2 deletions

View File

@ -867,10 +867,11 @@ func (s *SQLiteStmt) bind(args []namedValue) error {
case float64: case float64:
rv = C.sqlite3_bind_double(s.s, n, C.double(v)) rv = C.sqlite3_bind_double(s.s, n, C.double(v))
case []byte: case []byte:
if len(v) == 0 { ln := len(v)
if ln == 0 {
v = placeHolder v = placeHolder
} }
rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(len(v))) rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(ln))
case time.Time: case time.Time:
b := []byte(v.Format(SQLiteTimestampFormats[0])) b := []byte(v.Format(SQLiteTimestampFormats[0]))
rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b))) rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))