aboutsummaryrefslogtreecommitdiff
path: root/sqlite3.go
diff options
context:
space:
mode:
authorLucas Manuel Rodriguez <lucas@spideroak.com>2018-05-30 21:39:01 -0300
committerLucas Manuel Rodriguez <lucas@spideroak.com>2018-05-30 21:39:01 -0300
commit8d6d326be62813261950d3fe807f38a8977596b2 (patch)
tree45e0fec122e0e6d04f5c3d34cc9df8e2c71af803 /sqlite3.go
parentMerge pull request #577 from GJRTimmer/update/docs (diff)
downloadgolite-8d6d326be62813261950d3fe807f38a8977596b2.tar.gz
golite-8d6d326be62813261950d3fe807f38a8977596b2.tar.xz
Add nil check in bind and a test
Diffstat (limited to 'sqlite3.go')
-rw-r--r--sqlite3.go12
1 files changed, 8 insertions, 4 deletions
diff --git a/sqlite3.go b/sqlite3.go
index 75a5ee8..f9bbf12 100644
--- a/sqlite3.go
+++ b/sqlite3.go
@@ -1511,11 +1511,15 @@ func (s *SQLiteStmt) bind(args []namedValue) error {
case float64:
rv = C.sqlite3_bind_double(s.s, n, C.double(v))
case []byte:
- ln := len(v)
- if ln == 0 {
- v = placeHolder
+ if v == nil {
+ rv = C.sqlite3_bind_null(s.s, n)
+ } else {
+ ln := len(v)
+ if ln == 0 {
+ v = placeHolder
+ }
+ rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(ln))
}
- rv = C._sqlite3_bind_blob(s.s, n, unsafe.Pointer(&v[0]), C.int(ln))
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)))