NSInMemoryStoreType是否与group by fetch不兼容?

时间:2018-04-18 19:18:51

标签: swift xcode core-data

我希望NSPersistentContainer在单元测试中使用NSInMemoryStoreType类型的存储。我有一些实体,我想按日期分组,我想为它编写单元测试。

用于实例化内存中持久容器的代码:

let container = NSPersistentContainer(name: "DataModel")
let storeDescription = NSPersistentStoreDescription()
storeDescription.type = NSInMemoryStoreType
container.persistentStoreDescriptions = [storeDescription]
container.loadPersistentStores { (storeDescription, error) in
    print(storeDescription)
    if let loadingError = error {
       print(loadingError.localizedDescription)
    }
 }

错误我得到了:

caught "NSInvalidArgumentException", "Unsupported fetch request: store <NSMemoryObjectStore: 0x6000002c9bc0> (URL: file:///dev/null) does not support GROUP BY"

当我使用SQLite支持的NSPersistentContainer时,一切正常。内存容器是否可能与请求组不兼容?我认为各种类型的容器是可以互换的。

0 个答案:

没有答案