尽管记录在表中,但带有谓词的CoreData获取请求返回0条记录

时间:2017-10-04 15:06:12

标签: ios swift core-data

在这个问题上撕掉我的头发:

使用代码中的一个“where”参数执行简单请求。

let request = NSFetchRequest<NSFetchRequestResult>(entityName: FPEstServiceGroupData.entityName)
request.predicate = NSPredicate(format: "jobID == \(jobID)")
let list = try? moc.fetch(request)

获取0条记录:

CoreData: sql: SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZJOBID, t0.ZNAME, t0.ZSERVICEGROUPID, t0.ZSORTORDER, t0.ZJOB FROM ZFPESTSERVICEGROUPDATA t0 WHERE  t0.ZJOBID = ? 
CoreData: details: SQLite bind[0] = 59
CoreData: annotation: sql connection fetch time: 0.0003s
CoreData: annotation: fetch using NSSQLiteStatement <0x60400028fc30> on entity 'FPEstServiceGroupData' with sql text 'SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZJOBID, t0.ZNAME, t0.ZSERVICEGROUPID, t0.ZSORTORDER, t0.ZJOB FROM ZFPESTSERVICEGROUPDATA t0 WHERE  t0.ZJOBID = ? ' returned 0 rows with values: (
)
CoreData: annotation: total fetch execution time: 0.0004s for 0 rows.

同时,将CoreData mySQL文件放在磁盘上,执行相同的请求 - 返回数据:

echo "SELECT 0, t0.Z_PK, t0.Z_OPT, t0.ZJOBID, t0.ZNAME, t0.ZSERVICEGROUPID, t0.ZSORTORDER, t0.ZJOB FROM ZFPESTSERVICEGROUPDATA t0 WHERE  t0.ZJOBID = 59;" | sqlite3 FPData.sqlite
0|43|2|59|Design and Production|255|3|
0|44|2|59|Specification and Concept|254|2|
0|45|2|59|Web Design|256|3|

怎么可能?

0 个答案:

没有答案