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.
This replaces intermediate SQL logic used to setup views with a simple filter implemented in Rust. This makes the flow much easier to understand, and avoids re-parsing tables from JSON multiple times.
Specifically, this removes the following internal SQL functions and views:
powersync_viewsview and associated triggers.powersync_execpowersync_view_sql,powersync_trigger_delete_sql,powersync_trigger_insert_sql,powersync_trigger_update_sql.Instead, it adds the
ExistingViewstruct which holds the same fields aspowersync_viewsand uses the same query to read views. When we apply a schema, we use the parsed schema struct to find necessary updates instead of expressing that in SQL. The functions to create SQL for views and triggers has also been refactored to be Rust-internal.I've kept
powersync_drop_viewbecause it's used in a down migration we can't change. I had to migrate one up migration to use the new direct Rust calls in favor of the SQL layer, but the behavior should be the same.These changes are covered by existing tests. This still keeps
powersync_tablesaround, I will refactor that away in a follow-up PR.