forked from mirror/go-sqlcipher
Merge pull request #1 from fiber/master
inserting zero-length strings failed.
This commit is contained in:
commit
7d29362424
11
sqlite3.go
11
sqlite3.go
|
@ -154,8 +154,13 @@ func (s *SQLiteStmt) bind(args []interface{}) error {
|
||||||
case nil:
|
case nil:
|
||||||
rv = C.sqlite3_bind_null(s.s, n)
|
rv = C.sqlite3_bind_null(s.s, n)
|
||||||
case string:
|
case string:
|
||||||
b := []byte(v)
|
if len(v) == 0 {
|
||||||
rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))
|
b := []byte{0}
|
||||||
|
rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(0))
|
||||||
|
} else {
|
||||||
|
b := []byte(v)
|
||||||
|
rv = C._sqlite3_bind_text(s.s, n, (*C.char)(unsafe.Pointer(&b[0])), C.int(len(b)))
|
||||||
|
}
|
||||||
case int:
|
case int:
|
||||||
rv = C.sqlite3_bind_int(s.s, n, C.int(v))
|
rv = C.sqlite3_bind_int(s.s, n, C.int(v))
|
||||||
case int64:
|
case int64:
|
||||||
|
@ -213,7 +218,7 @@ func (s *SQLiteStmt) Exec(args []interface{}) (driver.Result, error) {
|
||||||
if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
|
if rv != C.SQLITE_ROW && rv != C.SQLITE_OK && rv != C.SQLITE_DONE {
|
||||||
return nil, errors.New(C.GoString(C.sqlite3_errmsg(s.c.db)))
|
return nil, errors.New(C.GoString(C.sqlite3_errmsg(s.c.db)))
|
||||||
}
|
}
|
||||||
return &SQLiteResult {s}, nil
|
return &SQLiteResult{s}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type SQLiteRows struct {
|
type SQLiteRows struct {
|
||||||
|
|
Loading…
Reference in New Issue