default(now())
on the same table sometimes yield different times
#13795
Labels
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
domain/client
Issue in the "Client" domain: Prisma Client, Prisma Studio etc.
kind/bug
A reported bug.
Milestone
Bug description
If there are two columns in the same table both with
@default(now())
they may get slightly different times. We noticed because we have a table that has both a created datetime and an updated datetime field which are both defaulted to now at create time, but we have a constraint thatupdated_dt >= created_dt
just as a sanity check.I suspect this may be related to or have the same underlying cause as #12572.
How to reproduce
This is a bit tricky to reproduce given that it's a race condition.
@default(now())
and using the highest level of precision.>=
to the other (or some other method of detecting the issue).Expected behavior
Any number of
@default(now())
columns should all get exactly the same timestamp.Prisma information
Here's a minimal example sufficient to see the bug
Prisma schema
And a test that should see the issue occurring
On my system I see the issue about 3% or so of the time so 100 repetitions should be enough to see it, but you may need to increase the number of iterations in the loop.
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: