Ian - we are seeing some new (strange) behaviour when using 5.2.0 now that doesn’t make a lot of sense. We use quite a lot of background threads for processing of reports etc. and for some reason now we are seeing a lot of failures when doing realm.objects(XXX.self).filter("id == %@, id) - which returns nil but when doing a listing of the results of realm.objects(XXX.self) we get a complete list of all the expected objects.
Is there some change in behaviour in RealmSwift 5.2.0 that might be cause a problem with realm queries - or any known bugs that we might be unaware of ? We have been using RealmSwift 4.4.1/macOS 10.15 with no problems but figure we should upgrade in preparation for an eventual migration to Mongo Realm.
I am puzzled as to how something like the following can return nil
let items = realm.objects(Item.self)
// This correctly lists all items
for item in items {
print("item: \(item.id), \(item.name)"
}
// and this always returns nil
let item = realm.object(ofType: Item.self, forPrimaryKey: id)
print("item: \(item?.id), \(item?.name)")
We will continue to investigate but if anyone has encountered anything like this before please let me know.
We do make extensive use of operation queues but have never had an issue in the past so unless there is some change between SwiftRealm 4.4.1 and 5.2.0 that may cause problems when using operation queues I can’t see why we should suddenly be encountering any problems.
The example above is on consecutive lines in the same function call so even with operation queues I would expect that would be executed on the same thread so I can’t think switching threads of execution could be the reason for the problems now.
One of the function calls that fails with 5.2.0 is the following:
Realm.asyncOpen(configuration: self.realmSyncConfig, callbackQueue: .global()) { (realm, error) in
completion(realm, error)
}
So has to be changed to the following:
Realm.asyncOpen(configuration: self.realmSyncConfig, callbackQueue: .main) { (realm, error) in
completion(realm, error)
}
Are there release notes for 5.2.0 that explain why this change is necessary ?