Skip to content

Conversation

@simolus3
Copy link
Contributor

@simolus3 simolus3 commented Jan 28, 2026

This refactors how CREATE VIEW, CREATE TRIGGER and CREATE INDEX statements are constructed in powersync_replace_schema.

The main motivation here is that we want to be able to generate triggers for raw tables as well. At the moment, CREATE TRIGGER statements are built from a string template specialized for the type of trigger and table. To be able to re-use some of that logic for raw tables in the future, this adds the SqlBuffer utility. It contains several methods to write identifiers, string literals and common fragments into a String buffer. In particular, writing into powersync_crud and defining the "header" of CREATE TRIGGER statements has been refactored into common method calls instead of being a large string literal.

This PR doesn't change the statements generated by the core extension (apart from whitespace). It drastically reduces the amount of intermediate String allocations, but I don't expect that to have a meaningful impact on performance.

This also updates Rust to 1.93, to be able to use the standardized fmt::from_fn, allowing us to provide a callback responsible describing how to format a fragment.

@simolus3 simolus3 marked this pull request as draft January 28, 2026 17:21
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