Skip to content

Preserve type when writing to ps_crud #117

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

Merged
merged 3 commits into from
Aug 6, 2025
Merged

Preserve type when writing to ps_crud #117

merged 3 commits into from
Aug 6, 2025

Conversation

simolus3
Copy link
Contributor

@simolus3 simolus3 commented Aug 6, 2025

The trigger responsible for writing into ps_crud used to apply the concat function on values in text columns to strip out the JSON subtype (avoiding e.g. SET foo = json_object() to be encoded as a nested JSON object instead of the string "{}").
Unfortunately, that logic was flawed in two ways:

  1. concat turns a null input value into an empty string.
  2. We've only applied this on text coumns. Since SQLite allows inserting text data into integer / real columns, we should apply this workaround on all columns.

As a solution, this introduces the powersync_strip_subtype function that preserves the type of the input value but will always replace the subtype of the value with 0.

@simolus3 simolus3 requested a review from rkistner August 6, 2025 14:36
@simolus3 simolus3 merged commit fff836a into main Aug 6, 2025
21 checks passed
@simolus3 simolus3 deleted the crud-types branch August 6, 2025 14:41
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