When a column is set using now it saves microsecond precision timestamp, then when I retrieve such a value using Contember it is rounded to millisecond. It can cause a bug when I copy this value to another column I would expect to them to be equal, which they will not.
The use-case for me was that had a updatedAt datetime column and a lastSynced datetime column and a view that checks if updatedAt > lastSynced that I should sync. After the sync operation I set updatedAt to lastSynced value... But that doesn't work - if updatedAt is 2024-10-11 09:46:06.309921+00, I can set lastSynced to 2024-10-11 09:46:06.309000+00 - and that's smaller value.
When a column is set using
now
it saves microsecond precision timestamp, then when I retrieve such a value using Contember it is rounded to millisecond. It can cause a bug when I copy this value to another column I would expect to them to be equal, which they will not.PostgreSQL uses 1 microsecond precision in
timestampz
column (source). Javascript uses millisecond precision(source).The use-case for me was that had a
updatedAt
datetime column and alastSynced
datetime column and a view that checks ifupdatedAt
>lastSynced
that I should sync. After the sync operation I setupdatedAt
tolastSynced
value... But that doesn't work - ifupdatedAt
is2024-10-11 09:46:06.309921+00
, I can setlastSynced
to2024-10-11 09:46:06.309000+00
- and that's smaller value.