Skip to content

Conversation

@simolus3
Copy link
Contributor

@simolus3 simolus3 commented Nov 7, 2025

This adds the timestamp_max_precision option for the config block when defining sync rules. Valid options are seconds, milliseconds, microsecondsandnanoseconds. Restricting precision is convenient in some cases, e.g. when other parts of an app can't handle sub-millisecond precision (something we noticed for some users migrating to edition: 2` which pads postgres timestamps to six digits).

When a source database provides a time value, it now also provides:

  • The inner precision of that time value (milliseconds for mongo, micros for mysql and postgres, nanoseconds for mssql). That doesn't mean that every value has that many fractional digits (postgres could e.g. emit 11:03:00.000000 as 11:03:00), but it reflects the maximum precision supported.
  • A default precision to use when no max precision is configured on sync rules. This matches the inner precision for mongo and postgres. For mysql, we use milliseconds as the default precision for backwards compatibility, while supporting microseconds as an opt-in.

Depending on compatibility options, a time value is then formatted with a precision of min(timestamp_max_precision ?? source.default_precision, source.inner_precision). We also pad values to ensure we consistently use the same amount of digits.

@changeset-bot
Copy link

changeset-bot bot commented Nov 7, 2025

🦋 Changeset detected

Latest commit: 86aa26f

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

This PR includes changesets to release 18 packages
Name Type
@powersync/service-image Minor
@powersync/service-module-postgres Patch
@powersync/service-module-mongodb Patch
@powersync/service-module-mysql Patch
@powersync/service-module-mssql Patch
@powersync/service-sync-rules Patch
@powersync/service-jpgwire Patch
@powersync/service-schema Minor
@powersync/service-core-tests Patch
@powersync/service-core Minor
@powersync/lib-services-framework Patch
@powersync/service-module-mongodb-storage Patch
@powersync/service-module-postgres-storage Patch
@powersync/lib-service-postgres Patch
@powersync/service-module-core Patch
test-client Patch
@powersync/service-rsocket-router Patch
@powersync/lib-service-mongodb 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 force-pushed the datetime-max-precision branch 2 times, most recently from e1513c5 to cb538c5 Compare December 4, 2025 11:32
@simolus3 simolus3 marked this pull request as ready for review December 4, 2025 11:33
@simolus3 simolus3 requested a review from rkistner December 4, 2025 11:33
@simolus3 simolus3 force-pushed the datetime-max-precision branch from cb538c5 to 86aa26f Compare December 4, 2025 22:01
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