[12.x] feat: use database default datetime precision #51793
Closed
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.
Hello!
This PR updates the default datetime precision to
nullwhich in turn uses the database default precision instead of defaulting to0across the board.As I mentioned in #51363 (specifically for Postgres), rounding issues can occur when using a non-default precision for that database. These rounding issues are eliminated when using the database default precision. For example, when using a precision of 0, Postgres will round
2000-01-01 23:59:59.999999up to the next day (2000-01-02 00:00:00) whereas no rounding will occur when using the default precision (6). At least in Postgres' case, using a lower precision does not have any storage benefits---a timestamp takes up 8 bytes regardless of the precision (however, this may not be the case for all databases).Note, that if we want more control in the application over the default precision on a per database level, then we could always create
getDatetimePrecisionmethods (similar togetDateFormat) on the schema grammars.Thanks!