mentrena / SyncKit

Automatic CloudKit synchronization
https://mentrena.github.io/SyncKit/
MIT License
505 stars 57 forks source link

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

Open sskjames opened 1 year ago

sskjames commented 1 year ago

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 commented 4 months ago

Hi @mentrena, any update on this?

aehlke commented 4 months ago

@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

sskjames commented 4 months ago

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.