Core Data Model Constraints ignored

Hi,


we do have a model that has a constraint on an attribute. Having the mergePolicy set in the context to "mergeByPropertyStoreTrumpMergePolicyType" as recommend everything works fine on iOS 11 devices. On iOS 12 suddenly the same app does not work and the model is not stored properly.


As far as we can see when we explicitly check for an already existing model with equal values in the constrained attribute and then just "update" the values everything works fine on iOS 11 and iOS 12.


Output from debug on iOS 12 when model is not stored:

CoreData: sql: INSERT INTO ZMACHINE...

CoreData: sql: UPDATE OR FAIL ZMACHINE...

CoreData: annotation: Optimistic locking failure for 0xd000000000680008 <x-coredata://6C7A3AA4-ED2B-46F9-A349-1215A6D4A394/.... During updateConstrainedValuesForRow, rows processed = 0. Row was updated.

CoreData: sql: ROLLBACK


Output from debug on iOS 11 where model is stored properly at the same situation:

CoreData: sql: UPDATE OR FAIL ZMACHINE ...

CoreData: sql: COMMIT


Is there a known issue for this on iOS 12 or is there any advice what we have might done wrong?


Thanks for your support,

Hosun

Replies

Did you try this?


container.loadPersistentStores(completionHandler: { (storeDescription, error) in
         
             container.viewContext.mergePolicy = NSMergeByPropertyObjectTrumpMergePolicy

Hi, did you fix your problem?
I have the same problem 😟