Skip to content

Properly track modificationDate in mock database - #574

Merged
mbrandonw merged 10 commits into
mainfrom
modification-date
Nov 5, 2026
Merged

mbrandonw merged 10 commits into
mainfrom
modification-date

Conversation

@mbrandonw

@mbrandonw mbrandonw commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

We are not currently setting modificationDate on CKRecords at all when they are saved in the mock database, and that has hidden potential bugs from us. So we now update the date when records are saved in the database, and fixed a bug along the way.

if let lastKnownDate = metadata?.lastKnownServerRecord?.modificationDate {
if let recordDate = record.modificationDate, lastKnownDate < recordDate {
if let lastKnownDate = metadata?.lastKnownServerRecord?._modificationDate {
if let recordDate = record._modificationDate, lastKnownDate <= recordDate {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This <= was a legitimate bug. It essentially meant we never cached the record before sending it off to CloudKit.

@mbrandonw
mbrandonw merged commit fb83b15 into main Nov 5, 2026
0 of 5 checks passed
@mbrandonw
mbrandonw deleted the modification-date branch November 5, 2026 21:57
mario-luis-dev added a commit to mario-luis-dev/sqlite-data that referenced this pull request Nov 9, 2026
Brings in what upstream merged after 1.12.1, unreleased: the upload sort
(pointfreeco#571), quotaExceeded saves parked and sent again (pointfreeco#335, pointfreeco#576), cached
records waiting for their parent (pointfreeco#567), CloudKit rate limiting (pointfreeco#569, pointfreeco#564),
the mock database's modification dates (pointfreeco#574) and the @fetch load race
(pointfreeco#536).

Conflicts, resolved:
- Upload sort: upstream's topologicallyAscending replaces the fork's own
  comparator; the fork's reference violation guard stays.
- enqueueLocallyPendingChanges takes upstream's scope, and still reads,
  queues and removes the queued notes in one write, so a note written while
  sync starts is queued exactly once. Notes written while sync is stopped
  record their database, as upstream's do.
- MockSyncEngineState takes upstream's single State, and keeps the fork's
  hook before adding changes and its rule that only the last save or
  deletion of a record stays queued.
- MockCloudDatabase takes upstream's records(for:) and keeps the fork's
  recordsLookupError and deletionLog.

The fork's own server lookups (settleDependents, the lost deletion and
leftover record checks) go through upstream's batched records(for:), so
they wait and try again when CloudKit limits the request rate.

Tests: MyDelegate is upstream's AccountChangedDelegate now; a share's
snapshot shows cloudkit.title as in upstream's; PreviewTests.delete() waits
for the preview timer's send to return before it ends (the fork's sends do
more after the server changes, and the test ended while one was still
returning in 4 of 5 full runs). Full suite: 421 pass, 6 runs in a row.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lukaskubanek added a commit to structuredpath/sqlite-data that referenced this pull request Nov 11, 2026
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