fix: diagnostics app dynamic schema #737
Merged
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.
Overview
The sync diagnostics tool creates a dynamic schema from the bucket operations received from the PowerSync service. This dynamic schema is used to populate the PowerSync SQLite views which are typically used in various SQL queries - such as in the
SQL console
page.The Rust implementation currently intercepts the PowerSync service commands and correctly attempts to process the operations into a dynamic schema. Unfortunately, processing the bucket operations currently only marks the dynamic schema as
dirty
- we still need to actually update the schema with the PowerSync client in order for SQL queries to use the views.This typically results in errors such as #736
This applies similar logic, as found in the RecordingStorageAdapter, for the
RustClientInterceptor
.Additional improvement:
We currently seem to be manually implementing
refreshSchema
using aDBAdapter
. This implementation does not trigger anyschemaChanged
listeners - which are used by watched queries. It is possible for an error condition as follows to occur:SQL Console page
and uses a query for a PowerSync view, before the View was detectedno such table ...
is displayedWe now use the
AbstractPowerSyncDatabase
refreshSchema
method to notify all listeners when the schema has changed. The watched queries should reevaluate the dependent tables and update.