Skip to content

Raw tables #654

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Raw tables #654

wants to merge 4 commits into from

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Jul 6, 2025

This adds support for "raw tables", which are managed by the user instead of being created as JSON views by PowerSync. Benefits include better performance for complex queries as well as support for more complex table definitions (including local table and column constraints).

To enable raw tables, one would currently first create a regular schema and then call withRawTables to add them (not sure if we should have a secondary parameter on the Schema constructor for this - perhaps after stabilizing this feature?). Raw tables consist of:

  1. A name, identifying the table name used by the sync service (so that the client knows to forward those operations to a raw table).
  2. A custom upsert statement to run for PUT ops.
  3. A custom delete statement to run for REMOVE ops.

The statements are defined as SQL with prepared statement parameters as well as a value source (which can currently either be the id column or a named column extracted from JSON). The syntax for that is not particularly nice at the moment (it reflects the internal JSON structure used by the core extension). There are multiple options to improve that here, but since the feature is explicitly marked as experimental we can improve on API changes once we better understand how this feature is used in practice.

Copy link

changeset-bot bot commented Jul 6, 2025

🦋 Changeset detected

Latest commit: 5369c52

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

This PR includes changesets to release 7 packages
Name Type
@powersync/common Minor
@powersync/node Minor
@powersync/web Minor
@powersync/react-native Minor
@powersync/op-sqlite Patch
@powersync/tanstack-react-query 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

@simolus3 simolus3 marked this pull request as ready for review July 11, 2025 14:44
@simolus3 simolus3 requested a review from stevensJourney July 11, 2025 14:44
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