Skip to content
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

[12.x] feat: use database default datetime precision #51793

Closed
wants to merge 1 commit into from

Conversation

calebdw
Copy link
Contributor

@calebdw calebdw commented Jun 13, 2024

Hello!

This PR updates the default datetime precision to null which in turn uses the database default precision instead of defaulting to 0 across 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.999999 up 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 getDatetimePrecision methods (similar to getDateFormat) on the schema grammars.

Thanks!

@calebdw calebdw changed the title [12.xfeat: use database default datetime precision [12.x] feat: use database default datetime precision Jun 13, 2024
@taylorotwell
Copy link
Member

@calebdw can we implement this instead with getDatetimePrecision so that users can just opt-in?

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.

None yet

2 participants