Repository navigation
Fix conflict-on-fetch scenario - #581
Open
lukaskubanek wants to merge 2 commits into
Open
lukaskubanek wants to merge 2 commits into
lukaskubanek wants to merge 2 commits into
Conversation
lukaskubanek
added a commit
to structuredpath/sqlite-data
that referenced
this pull request
Nov 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a small subset of #414, a PR that revamps merge conflict tests to cover all possible conflict scenarios.
This PR isolates a single scenario that the current implementation gets wrong and applies a minimal fix.
The first commit corrects a wrong assertion in one of the existing merge conflict tests, namely
serverRecordEditedAfterClientButProcessedBeforeClient. It edits the title on the client at t=30 and on the server at t=60, then processes the fetch before the client’s pending send goes out, a.k.a. conflict on fetch. It currently asserts that the client’s"Get milk"wins and ends up with the server’s timestamp. Under last edit wins the server’s"Buy milk"should win, as its edit is newer. This is the scenario reported in #354 and the remaining part of the divergence in #274.The second commit adjusts the merge in
CKRecord.update(with:row:columnNames:parentForeignKey:). So far a field changed on the client was always kept, regardless of timestamps. It is now kept only if the server did not change the field since the last known server record, or if the client’s change is newer than the server’s. Equal timestamps also favor the client, as elsewhere in the merge.Fixes #354 and fixes #274.