-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(@aws-amplify/datastore): correctly processing Delta Sync query response in RN #8196
fix(@aws-amplify/datastore): correctly processing Delta Sync query response in RN #8196
Conversation
Codecov Report
@@ Coverage Diff @@
## main #8196 +/- ##
==========================================
+ Coverage 76.91% 77.76% +0.84%
==========================================
Files 233 233
Lines 15228 16282 +1054
Branches 2979 3474 +495
==========================================
+ Hits 11713 12661 +948
- Misses 3288 3514 +226
+ Partials 227 107 -120
Continue to review full report at Codecov.
|
e606a6a
to
48b2d91
Compare
48b2d91
to
978eb31
Compare
978eb31
to
11f4fe2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 🎉
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Description of changes
Fixes the way a Delta Sync query response is processed in React Native.
Current behavior
The
batchSave
method in the AsyncStorageDatabase class separates incoming records from a delta query response into saves and deletes. It then sequentially performs amultiRemove
of all the delete operations, followed by amultiSet
of the save ops.So in the event that we have a create/update operation as well as a delete op for a record with the same
id
within the timespan of the delta sync record TTL, the create/update will win out locally, regardless of its_version
or_lastChangedAt
value.Change introduced
The change in this PR adds a step that iterates through the records from the delta sync response in the order they're received and creates a
Map
with a key ofid
from the records. The map is then iterated over before splitting out the records into saves and deletes. This way, only the latest version of the record for a given modelid
ends up getting persisted to the local store.Issue #, if available
#8158
Description of how you validated changes
Checklist
yarn test
passesN/A
Relevant documentation is changed or added (and PR referenced)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.