problems with timestamp #652
Unanswered
MarcRohrer
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Hi Marc Sounds exiting 😊 Timestamps are by default cast to js Date which isn't as high precision as postgres. You'll want to either explicitly cast to const sql = postgres({
types: {
date: {
to: 1184,
from: [1082, 1114, 1184],
serialize: x => x,
parse: x => x
}
}
}) |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I decided to reimplement all the datebase stuff, as Postgres.js
seems to be a way better solution.
Unfortunately I have run into a problem with timestamps.
I use them as part of the primary key and also in foreign keys.
I insert into a master table returning the default timestamp
column value generated with now() This gives:
Thu Jul 27 2023 14:29:51 GMT+0200 (Mitteleuropäische Sommerzeit)
This has to be used as part of the foreign key in other tables.
Everything shorter the a second vanished.
selecting from Postgres.js gives:
2023-07-27T12:09:58.385 Z
selecting within pgAdmin gives:
2023-07-27 14:09:58.385007+02
Of course foreign keys based on that value do not work at all.
Application logic requires two separate transactions.
Postgres.js and pgAdmin statements were identical.
All timestamps are with timezone.
Am I doing something wrong here?
Best wishes!
Marc
Beta Was this translation helpful? Give feedback.
All reactions