Fix metadata observation.#369
Merged
Merged
Conversation
mbrandonw
commented
Jan 12, 2026
| _ = try await syncEngine.share(record: remindersList) { _ in } | ||
|
|
||
| try await Task.sleep(for: .seconds(0.5)) | ||
| #expect(rows == [RecordNameAndIsShared(recordName: "1:remindersLists", isShared: true)]) |
Member
Author
There was a problem hiding this comment.
This test fails without these changes.
mbrandonw
commented
Jan 12, 2026
Comment on lines
+680
to
+682
| withKnownIssue("Query observation does not work with generated columns right now") { | ||
| #expect(rows == [RecordNameAndIsShared(recordName: "1:remindersLists", isShared: true)]) | ||
| } |
Member
Author
There was a problem hiding this comment.
Observation of generated columns does not currently work.
mbrandonw
commented
Jan 12, 2026
Comment on lines
+136
to
+138
| #sql(""" | ||
| ((\(QueryValue.self)."isShared" = 1) AND (\(self.share) OR 1)) | ||
| """) |
Member
Author
There was a problem hiding this comment.
We're employing two tricks here:
- First we are working around that generated columns are not observed by mixing in
("share" OR 1)into the query. That "touches" the "share" column for observation, but SQLite is able to effectively eliminate this term from the query and does not change what indexes it will use. - Further, by checking
"isShared" = 1explicitly we can help SQLite choose the index on "isShared`.
Note that we do want to still keep the generated column because it is what gives us an efficient index (better to index an integer column than a blob column).
Co-authored-by: Stephen Celis <stephen@stephencelis.com>
stephencelis
approved these changes
Jan 12, 2026
doozMen
pushed a commit
to doozMen/sqlite-data
that referenced
this pull request
Jan 22, 2026
* Fix metadata observation. * Workaround for generated column observation behavior. * optimization * clean up * clean up * fix * fix * update hasLastKnownServerRecord" * Update Sources/SQLiteData/CloudKit/SyncMetadata.swift Co-authored-by: Stephen Celis <stephen@stephencelis.com> * format * consistent order --------- Co-authored-by: Stephen Celis <stephen@stephencelis.com>
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.
Right now some changes to the metadatabase tables will not notify observers because the writes are made with the wrong connection.