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

Enable the configuring of the default precision for timestamp/datetime fields #5308

Open
fabis94 opened this issue Aug 23, 2022 · 3 comments · May be fixed by #5311
Open

Enable the configuring of the default precision for timestamp/datetime fields #5308

fabis94 opened this issue Aug 23, 2022 · 3 comments · May be fixed by #5311

Comments

@fabis94
Copy link

fabis94 commented Aug 23, 2022

Feature discussion / request

It's super annoying that Postgres stores high-precision timestamps, while JS can't even read them and ends up truncating the timestamp when it enters JS land, causing weird bugs later on when it comes to filtering & sorting.

Additionally, it doesn't appear that the latest version of Knex (2.2.0) allows projects using it to configure the default precision for timestamp/datetime fields. If this were possible, then we could just configure all new tables to use a lower precision value for all timestamp/datetime fields by default, without devs having to remember to set the correct precision.

So the request is - Please add a way to configure the default timestamp/datetime precision level.

@fabis94
Copy link
Author

fabis94 commented Aug 24, 2022

If it's unlikely for this to be addressed any time soon, I'm open to doing a PR for this, as long as I get some pointers about how this should be structured (just so I don't have to re-do it)

@fabis94
Copy link
Author

fabis94 commented Aug 24, 2022

I've added this feature myself (with integration tests): #5311

@ianchanning
Copy link

Until that gets approved, for the unfortunate souls that find their way here wondering why their pagination is failing, try using date_trunc('milliseconds', field).

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 a pull request may close this issue.

2 participants