How do I insert NULL into a column with swift
let myNullableValue: Double? = nil
fmdb.executeUpdate(
"INSERT INTO myTable(myNullableColumn) SELECT :myNullableValue"
, withParameterDictionary: [ "myNullableValue": myNullableValue ])
How do I insert NULL into a column with swift
let myNullableValue: Double? = nil
fmdb.executeUpdate(
"INSERT INTO myTable(myNullableColumn) SELECT :myNullableValue"
, withParameterDictionary: [ "myNullableValue": myNullableValue ])
From the FMDB source code at https://github.com/ccgus/fmdb/blob/master/src/fmdb/FMDatabase.m
- (void)bindObject:(id)obj toColumn:(int)idx inStatement:(sqlite3_stmt*)pStmt {
if ((!obj) || ((NSNull *)obj == [NSNull null])) {
sqlite3_bind_null(pStmt, idx);
}
// ...
one can conclude that a NSNull
value is inserted as a SQLite NULL
,
i.e. the parameter dictionary should be
[ "myNullableValue": NSNull() ]