aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authorXu Xinran <xxr@megvii.com>2017-06-14 19:55:09 +0800
committerXu Xinran <xxr@megvii.com>2017-06-14 19:55:09 +0800
commit308f5f1b2fae699cb38474136205cbab8f081019 (patch)
tree091811d5cbcf6644293da2af549e27b091cfdfe8 /sqlite3.go
parentMerge pull request #421 from flimzy/readme (diff)
downloadgolite-308f5f1b2fae699cb38474136205cbab8f081019.tar.gz
golite-308f5f1b2fae699cb38474136205cbab8f081019.tar.xz
Treat []byte{} as empty bytes instead of NULL.
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 33b9b9c..c3d5d98 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -772,11 +772,13 @@ func (s *SQLiteStmt) bind(args []namedValue) error {
case float64:
rv = C.sqlite3_bind_double(s.s, n, C.double(v))
case []byte:
+ var ptr *byte
if len(v) == 0 {
- rv = C._sqlite3_bind_blob(s.s, n, nil, 0)
+ ptr = &(make([]byte, 1)[0])
} else {
- rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(len(v)))
+ ptr = &v[0]
}
+ rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(ptr), C.int(len(v)))
case time.Time:
b := []byte(v.Format(SQLiteTimestampFormats[0]))
rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))