-
-
Notifications
You must be signed in to change notification settings - Fork 689
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
[BUG]: Postgres insert into timestamp with time zone removes milliseconds #1061
Comments
For me it inserts the milliseconds, but then selects by truncating them. So when I do a comparison in a where clause using data previously selected, I get unexpected results :/. |
This will be closed by #1659 |
You'll just need to use the |
Javascript Date supports milliseconds: > new Date()
2024-01-06T20:52:05.354Z
> new Date().getMilliseconds()
862 You said microseconds. I don't care about those but I'd like to keep the milliseconds. Can I do this to keep the "date" mode: timestamp("updated_at", {
mode: "date",
precision: 3, // 3 for milliseconds
}) According to the Postgres doc, Postgres default to the precision of the literal value, so it should have been 3 by default, no? |
Currently facing the same issue on a returning query, when I Select it normally it seems to work perfectly but for some reason the returning just removes the precision |
They just published a fix for this in the beta tag. Can you check if that fixes the issue? |
I'm currently at the gym, I beg give it a look in a couple of hours, just let me know the version and I'll upgrade |
@Angelelz Hey mate just to let u know |
Due to drizzle-team/drizzle-orm#1061 the events lose the ms precision on the timestamp. This PR converts the query to a raw query, so the precision is preserved.
This is still a problem for inserts that use
|
Should be fixed in I plan to release it in version |
I've previously replied to this and stated that it was working perfectly for me and it not being on stable was breaking my environment |
The issue I reported with |
Fixed in Please check release notes for more info |
What version of
drizzle-orm
are you using?0.27.2
What version of
drizzle-kit
are you using?0.19.12
Describe the Bug
When I insert a timestamp the milliseconds are removed.
lastSignInAt: timestamp('last_sign_in_at', { withTimezone: true }).notNull()
const now = new Date();
2023-08-15T21:36:45.531Z
const data = await db.insert(accounts).values({ lastSignInAt: now }).returning({ createdAt: accounts.createdAt });
2023-08-15T21:36:45.000Z
Might be related to issued #877
Expected behavior
Timestamp should be stored with milliseconds
In the example above, data.created should be
2023-08-15T21:36:45.531Z
Environment & setup
No response
The text was updated successfully, but these errors were encountered: