Skip to content

Fix Sync Streams signed string casts#645

Open
sravan27 wants to merge 1 commit into
powersync-ja:mainfrom
sravan27:fix-sync-streams-signed-cast
Open

Fix Sync Streams signed string casts#645
sravan27 wants to merge 1 commit into
powersync-ja:mainfrom
sravan27:fix-sync-streams-signed-cast

Conversation

@sravan27
Copy link
Copy Markdown

Summary

Fix Sync Streams expression evaluation for SQLite-style casts from signed numeric strings. The JavaScript evaluator previously parsed only unsigned numeric prefixes, so values like CAST('-12' AS integer) and CAST('-.5' AS numeric) evaluated as 0 instead of matching SQLite.

Why this matters

Sync rules can cast request parameters or JSON/text values before filtering rows. A signed value in a parameter or source row could therefore select the wrong rows in the JavaScript evaluator compared with SQLite semantics.

Changes

  • Allow optional + / - prefixes when parsing integer casts from strings.
  • Allow signed decimal and exponent forms for numeric casts, including .5 / -.5.
  • Add direct cast tests and scalar expression engine coverage.
  • Add a changeset for @powersync/service-sync-rules.

Verification

  • corepack pnpm --dir packages/sync-rules exec vitest test/src/sql_functions.test.ts --run
  • corepack pnpm --dir packages/sync-rules exec vitest test/src/sync_plan/engine/engine.test.ts --run -t "javascript.*signed string casts|javascript"
  • corepack pnpm --dir packages/sync-rules run build:tsc

Note: running the full scalar engine test file against local Node v23.7.0 fails in the existing SQLite-engine tests because Node's experimental node:sqlite returns object rows instead of the array rows expected by the suite. The JavaScript evaluator path and pure cast tests pass locally.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

🦋 Changeset detected

Latest commit: f840f31

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

This PR includes changesets to release 16 packages
Name Type
@powersync/service-sync-rules Patch
@powersync/service-core Patch
@powersync/lib-services-framework Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mssql Patch
@powersync/service-module-mysql Patch
@powersync/service-module-postgres-storage Patch
@powersync/service-module-postgres Patch
@powersync/service-module-core Patch
@powersync/service-image Patch
test-client Patch
@powersync/service-rsocket-router Patch
@powersync/lib-service-mongodb Patch
@powersync/lib-service-postgres Patch
@powersync/service-schema 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

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