Private tables should always be saved in private db.#310
Merged
Conversation
mbrandonw
commented
Nov 25, 2025
Comment on lines
+365
to
+373
| let zoneNameOverride: SQLQueryExpression<String?> | ||
| let ownerNameOverride: SQLQueryExpression<String?> | ||
| if privateTables.contains(where: { $0.base.tableName == Base.tableName }) { | ||
| zoneNameOverride = #sql("\(quote: defaultZone.zoneID.zoneName, delimiter: .text)") | ||
| ownerNameOverride = #sql("\(quote: defaultZone.zoneID.ownerName, delimiter: .text)") | ||
| } else { | ||
| zoneNameOverride = #sql("NULL") | ||
| ownerNameOverride = #sql("NULL") | ||
| } |
Member
Author
There was a problem hiding this comment.
This is the main fix. If we are getting parent information for a private table we can make sure the zone is the default zone. We could probably clean this up a bit, I mostly just focused on getting a passing test.
mbrandonw
commented
Nov 25, 2025
| } | ||
|
|
||
| @available(iOS 17, macOS 14, tvOS 17, watchOS 10, *) | ||
| @Test func privateTablesStayInPrivateDatabase() async throws { |
Member
Author
There was a problem hiding this comment.
This test failed before the fix because when processing record changes in the private database a failure would be emitted since there were no changes to process.
mbrandonw
commented
Nov 25, 2025
| databaseScope: .private, | ||
| storage: [ | ||
| [0]: CKRecord( | ||
| recordID: CKRecord.ID(1:remindersListPrivates/zone/__defaultOwner__), |
Member
Author
There was a problem hiding this comment.
The fact that this record is in the private database shows the fix has worked.
stephencelis
approved these changes
Nov 25, 2025
bok-
pushed a commit
to bok-/sqlite-data-with-traits
that referenced
this pull request
Dec 15, 2025
* Private tables should always be saved in private db. * snapshots
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.
We currently have a bug with private tables + sharing where we accidentally try to save rows from the private table in the shared db, and that causes a permission failure. This PR makes sure that private tables are always saved in the private DB.