Open cfis opened 9 years ago
It is probably best to see if @jeffarena remember anything about it.
A revert of that commit would cause breakage of local deletes due to the set comparison here:
You would end up comparing localObjects
(retrieved from self.privateContext
) with managedObjectsInMappingRequest
(retrieved from self.managedObjectContext
). A proper fix would likely involve rolling back https://github.com/RestKit/RestKit/commit/129cc6f052e31116ce12502d1246f04ddd5ad85b and then refactoring of the deleteLocalObjectsMissingFromMappingResult:error:
method to avoid cross-context object comparisons.
I believe we are running into this issue as well: recent changes to a managed object are not reflected in the query results, but are reflected on the objects returned.
For example, searching for is_favorite != nil returns 2 results. Set is_favorite to nil for one of them. Query again, returns same 2 results (but one is marked as favorite and one is not when analyzing the objects returned)
@jeffarena is there any progress on this issue? we will likely be removing rest kit from several of our projects if this is not resolved.
Please see this issue on stack overflow: http://stackoverflow.com/questions/31082661/core-data-fetch-predicate-nil-check-failing-unexpected-results
Thank you for your time.
+1
I haven't had the time to investigate this, but a PR with a fix would be very much appreciated :)
@cfis could you please create a test that reproduces this issue?
The objects returned by cached responses are incorrect. They returned objects are in the privateContext of the request operation, and then are sent via callbacks to the main thread (and main context). This results in CoreData threading violations (just turn on -com.apple.CoreData.ConcurrencyDebug 1 to see).
The incorrect code is here:
https://github.com/RestKit/RestKit/blob/development/Code/Network/RKManagedObjectRequestOperation.m#L594
This code was originally correct, but was changed by this commit three years ago 129cc6f052e3111. The commit mentions something about local deletes, but I don't know the code well enough to understand what the change accomplished.
Its easy of course to revert that commit, but I don't know the consequences of that on the local delete issue. Or if the change should not be reverted, then the objects need to be mapped from the private context to the main context.
Happy to fix either way, just need some guidance.