Skip to content

feat: refresh watched queries on schema changes #377

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

Merged
merged 23 commits into from
Nov 7, 2024

Conversation

Chriztiaan
Copy link
Contributor

@Chriztiaan Chriztiaan commented Oct 31, 2024

This PR introduces fixes for problems encountered when schema changes are made against tables being depended on in watched queries (watch() and hooks/composable).

The problem affected web and react-native in different ways.

  • For web the solution is to have the watched queries register a listener which is triggered on schema change. This fix was applied to common/AbstractPowerSyncDatabase's watch functions, react, tanstack-react-query, and vue.
  • For react-native in combination with the web fix, the underlying RNQS or OP-sqlite needs to a pragma call on all read/write connections. The OP-sqlite change is included in this PR, while the RNQS change is available here.

A similar API addition for refreshSchema() was made to the Dart sqlite-async project here.

This PR also includes a small fix to the optional sync's demo (this demo was used for testing the original bug).

Testing

Originally, after the schema was changed - inserts wouldn't reflect in the UI for watch watched queries. Inserts do reflect now as expected.

Copy link

changeset-bot bot commented Oct 31, 2024

🦋 Changeset detected

Latest commit: 506aaee

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@powersync/common Minor
@powersync/op-sqlite Minor
@powersync/react-native Minor
@powersync/web Minor
@powersync/vue Patch
@powersync/tanstack-react-query Patch
@powersync/react Patch
@powersync/diagnostics-app Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Chriztiaan Chriztiaan marked this pull request as ready for review November 5, 2024 07:36
@Chriztiaan Chriztiaan requested review from mugikhan and removed request for DominicGBauer November 5, 2024 07:46
stevensJourney
stevensJourney previously approved these changes Nov 6, 2024
# Conflicts:
#	packages/react-native/package.json
#	pnpm-lock.yaml
@Chriztiaan Chriztiaan merged commit 7b49661 into main Nov 7, 2024
6 checks passed
@Chriztiaan Chriztiaan deleted the feat/watch-schema-changes branch November 7, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants