paulw11 / Seam3

Cloudkit based persistent store for Core Data
Other
209 stars 25 forks source link

Adding similar records results in the first being overwritten #124

Closed daviddelmonte closed 4 years ago

daviddelmonte commented 5 years ago

Adding similar records results in the first being overwritten in Core Data, but Cloudkit looks fine.

I have a project that include tag records. These records include a TagId and a ProjectId. There can be many tag records for a project, and a project can contain several tags.

To flatten the data, I allow each project record to have its own version of its tag. So record A can have tag 1 and tag 2. And record B can have tag 3, but also tag 1.

I'm finding that the records for tag 1 are created in CloudKit (see the screenshots, and count the number of records. Records for the second project using tag 1 are overwriting the first record within the CoreData model.

One can see that the record count in CK is 8, while in CD, it is 7.

I'm also getting some console messages that might help someone help me pinpoint the cause:

seam error Operation error: Error saving record <CKRecordID: 0x7fa555a30860; recordName=0C1F3516-6293-4568-A036-34BD29B94BA3, zoneID=SMStoreCloudStore_CustomZone:__defaultOwner__> to server: record to insert already exists

seam error Operation error: Record <CKRecordID: 0x7fa555a12b10; recordName=ACEA8441-860B-472E-BD9D-4FC6B039A812, zoneID=SMStoreCloudStore_CustomZone:__defaultOwner__> will not be saved because of previous error in atomic zone

seam error Operation error: Error saving record <CKRecordID: 0x7fa555a2eea0; recordName=01EC1645-0BDE-458D-A89F-AE2FE5B31A89, zoneID=SMStoreCloudStore_CustomZone:__defaultOwner__> to server: record to insert already exists

seam error Operation error: Error saving record <CKRecordID: 0x7fa555a46de0; recordName=D4E39C53-4C35-4F34-95A7-704096D7362F, zoneID=SMStoreCloudStore_CustomZone:__defaultOwner__> to server: client oplock error updating record

Here are the two relevant screenshots:

CoreDataView Screen Shot 2019-11-20 at 6 34 06 PM

I can post relevant code if requested, and I can also push this issue to StackOverflow if requested.

Has anyone else experienced this and/or found a workaround?

Thanks