-
Notifications
You must be signed in to change notification settings - Fork 46
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
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
73daf49
update watched queries when schema updated
stevensJourney 1125911
Using iterateAsyncListeners for schema change event.
Chriztiaan 4dc0e6d
Fixed throttle overflow test breaking.
Chriztiaan e27e2b6
Fix iterating schemaChange listeners causing infinite loop.
Chriztiaan 7e8f1a1
Broke out triggerWatchQuery to separate function.
Chriztiaan 65f7773
Updated watchWithAsyncGenerator to use watchWithCallback instead of o…
Chriztiaan 3ddc420
Separated runOnSchemaChange from AbstractPowerSyncData.
Chriztiaan 3deaa97
useQuery will recalculate dependant tables if schema changes. Fixed a…
Chriztiaan 9c2576b
useSuspenseQuery will recalculate tables on a schema change. Fix unit…
Chriztiaan 55260d4
Merge branch 'main' into feat/watch-schema-changes
Chriztiaan 9cc05f8
Tanstack queries will nou recalculate dependent tables when schema ch…
Chriztiaan ab34416
Changeset entries.
Chriztiaan 7816d88
Vue queries will recalculate dependent tables on schema change.
Chriztiaan 515b6fc
Added refreshSchema to DBAdapter.
Chriztiaan 5d8fb96
Added changeset entries for react-native, web, and op-sqlite.
Chriztiaan 185d766
Merge branch 'main' into feat/watch-schema-changes
Chriztiaan 28d0fd2
Bumped react-native rnqslite version.
Chriztiaan 19c4df8
Merge branch 'main' into feat/watch-schema-changes
Chriztiaan e0c72a1
Merge branch 'main' into feat/watch-schema-changes
Chriztiaan 21a0f0c
Merge branch 'feat/watch-schema-changes' of github.com:powersync-ja/p…
Chriztiaan 944bc83
Updated OPSqliteAdapter with incoming changes.
Chriztiaan ac2839f
Minor comment and await on initialized in OPSQlite refreshSchema.
Chriztiaan 506aaee
Merge branch 'main' into feat/watch-schema-changes
Chriztiaan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@powersync/common': minor | ||
--- | ||
|
||
Updated watch functions to recalculate depedendent tables if schema is updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
'@powersync/op-sqlite': minor | ||
'@powersync/react-native': minor | ||
'@powersync/web': minor | ||
--- | ||
|
||
Added `refreshSchema()` which will cause all connections to be aware of a schema change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@powersync/vue': patch | ||
--- | ||
|
||
Queries will recalculate dependent tables if schema is updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@powersync/tanstack-react-query': patch | ||
'@powersync/react': patch | ||
--- | ||
|
||
Queries will recalculate dependent tables if schema is updated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { AbstractPowerSyncDatabase, SQLWatchOptions } from './AbstractPowerSyncDatabase.js'; | ||
|
||
export function runOnSchemaChange( | ||
callback: (signal: AbortSignal) => void, | ||
db: AbstractPowerSyncDatabase, | ||
options?: SQLWatchOptions | ||
): void { | ||
const triggerWatchedQuery = () => { | ||
const abortController = new AbortController(); | ||
let disposeSchemaListener: (() => void) | null = null; | ||
const stopWatching = () => { | ||
abortController.abort('Abort triggered'); | ||
disposeSchemaListener?.(); | ||
disposeSchemaListener = null; | ||
// Stop listening to upstream abort for this watch | ||
options?.signal?.removeEventListener('abort', stopWatching); | ||
}; | ||
|
||
options?.signal?.addEventListener('abort', stopWatching); | ||
disposeSchemaListener = db.registerListener({ | ||
schemaChanged: async () => { | ||
stopWatching(); | ||
// Re trigger the watched query (recursively), setTimeout ensures that we don't modify the list of listeners while iterating through them | ||
setTimeout(() => triggerWatchedQuery(), 0); | ||
} | ||
}); | ||
callback(abortController.signal); | ||
}; | ||
|
||
triggerWatchedQuery(); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.