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

Can's set zero precision to timestamp #4784

Closed
6aKa opened this issue Oct 30, 2021 · 2 comments · Fixed by #4786
Closed

Can's set zero precision to timestamp #4784

6aKa opened this issue Oct 30, 2021 · 2 comments · Fixed by #4786

Comments

@6aKa
Copy link

6aKa commented Oct 30, 2021

Environment

Knex version: Knex Local version: 0.95.12
Database + version: psql (PostgreSQL) 13.4
OS: MacOS Monterey 12.0.1 (21A559)

Bug

In migration create field
t.timestamp('confirmed_at', {useTz: false, precision: 0});

     Column      |            Type             | Collation | Nullable |      Default      | Storage  | Stats target | Description
-----------------+-----------------------------+-----------+----------+-------------------+----------+--------------+-------------
 confirmed_at    | timestamp without time zone |           |          |                   | plain    |              |

Expected timestamp(0) without time zone

From PostgreSQL documentation

time, timestamp, and interval accept an optional precision value p which specifies the number of fractional digits retained in the seconds field. By default, there is no explicit bound on precision. The allowed range of p is from 0 to 6 for the timestamp and interval types.
@OlivierCavadenti
Copy link
Collaborator

Thanks for the report.

I check quickly and it's seems the problem occurs with precision = 0 because of that check during the column compile phase :

precision = precision ? '(' + precision + ')' : '';

I will make a fix quickly.

OlivierCavadenti added a commit to OlivierCavadenti/knex that referenced this issue Oct 30, 2021
OlivierCavadenti added a commit to OlivierCavadenti/knex that referenced this issue Oct 30, 2021
OlivierCavadenti added a commit to OlivierCavadenti/knex that referenced this issue Oct 30, 2021
OlivierCavadenti added a commit to OlivierCavadenti/knex that referenced this issue Oct 30, 2021
OlivierCavadenti added a commit to AbeonaPascha/knex that referenced this issue Nov 4, 2021
@kibertoad
Copy link
Collaborator

Released in 1.0.1.

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.

3 participants