Skip to content

WIP: Raw tables #87

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

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

WIP: Raw tables #87

wants to merge 5 commits into from

Conversation

simolus3
Copy link
Contributor

This adds support for raw tables which, instead of being views over JSON data, are meant to be created by users as regular tables.

This prepares the core extension with support for that, but there are still a lot of uncertainties around the exact interface to use. As an experiment here, we:

  1. Expand the schema JSON to include an additional raw_tables array in additon to the array of JSON-backed tables. Raw tables are not created by the core extension.
  2. Each raw table has a name identifiying it, as well as an SQL statements for upserts (to handle PUT and PATCH operations) and deletes.
  3. These statements can use parameters, which the core extension can bind to column values (either the ID or extracted data).
  4. We need to be aware of the schema during the sync operation to know which statements to use. This feature relies on the new sync logic in the core extension, and involves clients passing the schema to the first powersync_control invocation.

For local writes, clients would typically install triggers on raw tables. These triggers need to be able to distinguish between actual local writes from the app and writes made to apply sync operations. For that, this introduces the powersync_in_sync_operation() function which returns TRUE when a sync is active on the connection (so WHEN NOT powersync_in_sync_operation() can be used as a guard on the trigger).

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.

1 participant