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.
Description
This PR fixes a bug where watched queries would sometimes fail to reflect updates from
writeTransaction
s.Watched queries don't update due to a race condition where the table change hook is fired before the changes have been committed. The read connections re-execute watched queries, but don't return the latest updates.
This builds off the work from powersync-ja/react-native-quick-sqlite#13 which adds new methods for receiving table change updates once changes have been committed to the DB.
The common
DBAdapter
interface has been updated in order to be compatible with the previous DB connection API for single table updates and the recently updated Batch updates.Testing:
This was tested using the React Native Todolist app.
Before
With the current SDK certain operations only reflect in watched queries when refreshed. Initially Item
3
was deleted, but still remains on the view until a new item is created. There is also a large delay between creating the item and it appearing on screen. This is caused by the initial table update not firing at the correct time, the query is refreshed once the sync bucket is refreshed (due to syncing).old_write_tx.mov
After
With the new updates all operations are reflected in the watched query in a timely manner.
new_write_tx.mov
TODO: