Skip to content

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: 2017270

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
Copy link
Collaborator

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good. I had some minor questions.

Copy link
Collaborator

@stevensJourney stevensJourney left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy with this from my side.

@simolus3 simolus3 merged commit ab33799 into main Jul 14, 2025
9 checks passed
@simolus3 simolus3 deleted the raw-tables branch July 14, 2025 15:28
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.

3 participants