create()
fails with DateTime
type column as part of PRIMARY KEY
in mssql server
#10378
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
kind/bug
A reported bug.
team/client
Issue for team Client.
topic: create()
topic: dates / DateTime
topic: sql server
Microsoft SQL Server
Bug description
When db table has datetime type column as part of primary key, create fails because datetime in Javascript contains milliseconds which are ignored by mssql. Now stored field (without milliseconds) doesn't match with the datetime with milliseconds hence the operation fails.
How to reproduce
Assume db table like which has datetime as PRIMARY KEY
and prisma insert operation like below -
new Date contains millisecond information which is not supported by mssql server (or perhaps other databases as well). Now, mssql ignores these milliseconds and saves the time after setting milliseconds to zero. Now while trying to fetch the newly inserted record by the date (which contains milliseconds) it doesn't find the match hence rollback the transaction.
A quick hack to make it work for this is to have insert operation like below -
Expected behavior
Prisma should get rid of milliseconds and try to fetch field without milliseconds.
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: