SyncKit icon indicating copy to clipboard operation
SyncKit copied to clipboard

Parent record's modified date time updated when a child record was synced the first time

Open sskjames opened this issue 2 years ago • 3 comments

I have two Realm entities where one has a relationship with the other.

class Child: Object, ParentKey {
  @objc dynamic var id: String = ""
  @objc dynamic var parent: Parent?

   static func parentKey() -> String {
        return "parent"
    }
}

class Parent: Object {
}

The Parent record is created and synced to CloudKit. But when the very first Child record is created, I observed that the modifiedDateTime in the CloudKit metadata of the Parent being updated to the Child record's created date time.

As a result, the next time when I make changes to the Parent record, I get a conflict with the CloudKit error code 14, and the changes are lost.

When I make further changes to the Parent or Child record, I don't face any issue. When I create additional Child records, I don't face any issue either.

Appreciate any help I could receive to solve this.

sskjames avatar Aug 15 '23 04:08 sskjames

Hi @mentrena, any update on this?

sskjames avatar Apr 30 '24 09:04 sskjames

@sskjames I don't think this is maintained anymore especially now that SwiftData is on the horizon as the new standard

I'm maintaining a fork here: https://github.com/lake-of-fire/BigSyncKit for RealmSwift only though.

I'm investigating this bug in my fork now.

edit: It should not be an issue in my fork because I use a custom modifiedAt field with conflict resolution as such: https://github.com/lake-of-fire/BigSyncKit/blob/4cb7cec2da1f2e42aad442024b92e8b99a547725/Sources/BigSyncKit/RealmSwift/RealmSwiftAdapter.swift#L686-L699

aehlke avatar Apr 30 '24 17:04 aehlke

Hi @aehlke, thank you very much for maintaining the fork. I'll have a look at it and see whether it will fit our usecase.

sskjames avatar May 06 '24 01:05 sskjames