|
|
@@ -338,7 +338,13 @@ - (void)bindObject:(id)obj toColumn:(int)idx inStatement:(sqlite3_stmt*)pStmt {
|
|
|
|
|
|
// FIXME - someday check the return codes on these binds.
|
|
|
else if ([obj isKindOfClass:[NSData class]]) {
|
|
|
- sqlite3_bind_blob(pStmt, idx, [obj bytes], (int)[obj length], SQLITE_STATIC);
|
|
|
+ const void *bytes = [obj bytes];
|
|
|
+ if (!bytes) {
|
|
|
+ // it's an empty NSData object, aka [NSData data].
|
|
|
+ // Don't pass a NULL pointer, or sqlite will bind a SQL null instead of a blob.
|
|
|
+ bytes = "";
|
|
|
+ }
|
|
|
+ sqlite3_bind_blob(pStmt, idx, bytes, (int)[obj length], SQLITE_STATIC);
|
|
|
}
|
|
|
else if ([obj isKindOfClass:[NSDate class]]) {
|
|
|
sqlite3_bind_double(pStmt, idx, [obj timeIntervalSince1970]);
|