Skip to content

Support for ancestor records in mock cloud database#389

Open
mbrandonw wants to merge 7 commits intomainfrom
ancestor
Open

Support for ancestor records in mock cloud database#389
mbrandonw wants to merge 7 commits intomainfrom
ancestor

Conversation

@mbrandonw
Copy link
Member

If we wanna get into 3-way merging stuff we should have a representation of this in our mock cloud database.

Comment on lines -30 to +51
package var records: [CKRecord.ID: CKRecord] = [:]
package var entries: [CKRecord.ID: RecordEntry] = [:]
}

package struct RecordEntry {
package var record: CKRecord
package var history: [Int: CKRecord]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beefed this up so that we don't hold just a record at a record ID, but also a history that maps record change tag to past record.

@lukaskubanek
Copy link
Contributor

Chiming in to note that server-side history tracking isn’t required for conflict resolution based on a three-way merge. As mentioned earlier, CloudKit only provides the client/server/ancestor records for conflicts on send. Conflicts on fetch are not detected, which is why a per-row ancestor record needs to be tracked on the client in SyncMetadata. And with a small change to the codebase, SyncMetadata._lastKnownServerRecordAllFields could serve this purpose. There’s no need to keep the full history (the latest ancestor is sufficient) and no need for server mocking (the entire approach can be implemented on the client side).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants