Description
When synchronizing Date fields between the local SQLite database (with the default serialization strategy) and CloudKit, Date values that should be identical are often detected as changed in CKRecord.update(with:row:columnNames:parentForeignKey:).
I observed this with Reminder.dueDate in the Reminders example app:
(lldb) p (other.encryptedValues[key]! as Date).timeIntervalSinceReferenceDate
(TimeInterval) 782983984.64199996
(lldb) p value.timeIntervalSinceReferenceDate
(TimeInterval) 782983984.64100003
(lldb) p other.encryptedValues[key] == value
(Bool) false
Although both SQLite and CloudKit appear to serialize Date values with millisecond precision, the repeated conversion introduces rounding errors. As a result, the equality check of Date via bit-exact comparison fails, and the value is mistakenly treated as modified.
Not sure whether the correct solution is to normalize all persisted dates or to compare with a tolerance, but in any case, we should prevent reporting false positives to avoid divergence between the local SQLite and CloudKit databases.
Checklist
Expected behavior
No response
Actual behavior
No response
Reproducing project
No response
SQLiteData version information
main
Sharing version information
No response
GRDB version information
No response
Destination operating system
iOS 18 / macOS 15
Xcode version information
26.1 β3
Swift Compiler version information
swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
Target: arm64-apple-macosx15.0
Description
When synchronizing
Datefields between the local SQLite database (with the default serialization strategy) and CloudKit,Datevalues that should be identical are often detected as changed inCKRecord.update(with:row:columnNames:parentForeignKey:).I observed this with
Reminder.dueDatein the Reminders example app:Although both SQLite and CloudKit appear to serialize
Datevalues with millisecond precision, the repeated conversion introduces rounding errors. As a result, the equality check ofDatevia bit-exact comparison fails, and the value is mistakenly treated as modified.Not sure whether the correct solution is to normalize all persisted dates or to compare with a tolerance, but in any case, we should prevent reporting false positives to avoid divergence between the local SQLite and CloudKit databases.
Checklist
mainbranch of this package.Expected behavior
No response
Actual behavior
No response
Reproducing project
No response
SQLiteData version information
main
Sharing version information
No response
GRDB version information
No response
Destination operating system
iOS 18 / macOS 15
Xcode version information
26.1 β3
Swift Compiler version information