-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(datastore): full sync when sync predicate changes #2757
Conversation
@lawmicha What is the status of this fix? is it going to be merged soon? |
ab127f7
to
b71b79a
Compare
b71b79a
to
331d746
Compare
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #2757 +/- ##
==========================================
- Coverage 67.96% 67.91% -0.05%
==========================================
Files 1077 1079 +2
Lines 35988 36127 +139
==========================================
+ Hits 24459 24536 +77
- Misses 11529 11591 +62
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
331d746
to
3f8504c
Compare
Hey @MahmoudAlsamman, I'm picking this PR back up and will provide an update soon! |
3f8504c
to
eef1484
Compare
eef1484
to
9e320ec
Compare
Issue #
#3383
Description
Perform a full sync when the sync expression for the model changes. To do this, we have to persist and retrieve it from the sync metadata table for comparison with the incoming sync predicate.
The sync expression can be made up of mulitple predicates, each correponding to a specific model. InitialSyncOperation extracts out the first sync predicate from the sync expression for the corresponding model. This
QueryPredicate
is then used to compare with the existing persisted sync predicate from the last sync run, stored in the ModelSyncMetadata table.We extend the ModelSyncMetadata table to add a new column, make QueryPredicate Encodable so we can encode the sync predicate and store it as a String. The encoder has the output formatting set to
.sortedKeys
to make sure the same string is generated every time. We do a string comparision of the incoming sync predicate with the persisted one to see if it was changed.We do a full sync on these scenarios:
When there are matching sync predicates or no previous and current sync predicates, then the sync type falls back to the previous logic to determine full or delta (based on the sync interval).
Existing app upgrade scenario
Extending the ModelSyncMetadata table means that existing apps that have already created the table will not recreate it for the new column. The most optimal way, without deleting the local data, is to add a new column if we can detect the column doesn't exist. This is in the ModelSyncMetadataMigration logic.
Verification
General Checklist
Given When Then
inline code documentation and are named accordinglytestThing_condition_expectation()
If breaking change, documentation/changelog update with migration instructionsBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.