Skip to content

Infer sync statements for raw tables#164

Open
simolus3 wants to merge 5 commits intomainfrom
infer-raw-table-statements
Open

Infer sync statements for raw tables#164
simolus3 wants to merge 5 commits intomainfrom
infer-raw-table-statements

Conversation

@simolus3
Copy link
Contributor

@simolus3 simolus3 commented Feb 12, 2026

This builds on top of the new raw table options introduced in #163.

This makes the put and delete statements set on raw tables optional. If they're omitted, the sync_local step of each sync will attempt to infer them by looking at the actual columns of the table:

  1. The id column will be set to the affected row id.
  2. Other columns will be bound to extracted JSON values of the same name.
    • Columns marked as local-only are ignored.

Inferred statements are cached until pragma schema_version returns a new value.

For now, this does not support a dedicated _rest column that would be inferred by default. Users interested in that would have to use explicit statements instead.

Copy link
Contributor

@rkistner rkistner left a comment

Choose a reason for hiding this comment

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

Is it feasible to add a test for the generated SQL? Even if it's just a Rust unit test rather than an "end-to-end" Dart one.

@simolus3 simolus3 force-pushed the infer-raw-table-statements branch from bd4886d to 7e1a6a7 Compare February 16, 2026 08:22
@simolus3
Copy link
Contributor Author

Is it feasible to add a test for the generated SQL? Even if it's just a Rust unit test rather than an "end-to-end" Dart one.

We can pretty much only test this in Rust because the statements are internal to the extension and not exposed. I've added tests at the end of raw_tables.rs now.

rkistner
rkistner previously approved these changes Feb 16, 2026
Base automatically changed from raw-table-triggers to main February 16, 2026 09:15
@simolus3 simolus3 dismissed rkistner’s stale review February 16, 2026 09:15

The base branch was changed.

@simolus3 simolus3 force-pushed the infer-raw-table-statements branch from b7af9ba to 9d54a31 Compare February 16, 2026 09:16
@simolus3 simolus3 marked this pull request as ready for review February 16, 2026 09:17
@simolus3 simolus3 requested a review from rkistner February 16, 2026 09:17
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.

2 participants