diff options
author | mattn <mattn.jp@gmail.com> | 2017-08-22 13:32:16 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-22 13:32:16 +0900 |
commit | 144deb6596cd6dbb49158b3d6f6a0e742715f9a5 (patch) | |
tree | cbc91e77b2908af25c7d2456488c586fdfdbf753 /sqlite3.go | |
parent | fix test (diff) | |
parent | Improved TestNilAndEmptyBytes (diff) | |
download | golite-144deb6596cd6dbb49158b3d6f6a0e742715f9a5.tar.gz golite-144deb6596cd6dbb49158b3d6f6a0e742715f9a5.tar.xz |
Merge pull request #454 from gholt/master
Fix to better handle NULL values in TEXT and BLOB columns.
Diffstat (limited to 'sqlite3.go')
-rw-r--r-- | sqlite3.go | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -867,10 +867,11 @@ func (s *SQLiteStmt) bind(args []namedValue) error { case float64: rv = C.sqlite3_bind_double(s.s, n, C.double(v)) case []byte: - if len(v) == 0 { + ln := len(v) + if ln == 0 { 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: b := []byte(v.Format(SQLiteTimestampFormats[0])) rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b))) |