我在 iOS 上使用 FMDB,尝试使用如下语句查询表,
select * from test where foo isNull
在 sqlite C API 中,这最终使用此 API 绑定到 null,
int sqlite3_bind_null(sqlite3_stmt*, int);
这是行不通的。通过 fmdb 调用的选择似乎将列正确绑定到 null 没有找到匹配的记录。
如果在 sqlite3 命令行会话中执行以下命令,它可以工作,但不能通过 FMDB 的 sqlite C API。
select * from test where foo isNull;
这是重现问题的 fmdb 代码。看起来 fmdb 正在执行调用 sqlite3_bind_null 的正确步骤。
NSString *stmt = @"select * from test where shipToCode=:foo";
NSDictionary *dict = @{@"foo" : [NSNull null]};
FMResultSet *rs = [db executeQuery:stmt withParameterDictionary:dict];
int count = 0;
while ([rs next]) {
count++;
}
NSLog(@"Count %d", count);