Add option to restrict datetime precision #389
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Extracting sub-millisecond accuracy out of MySQL will require powersync-ja/powersync-mysql-zongji#15, so this is WIP.
This adds the
timestamp_max_precisionoption for theconfigblock when defining sync rules. Valid options areseconds,millisecondsandmicroseconds. 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 toedition: 2which pads postgres timestamps to six digits).When a source database provides a time value, it now also provides:
11:03:00.000000as11:03:00), but it reflects the maximum precision supported.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.