upsert()
fails on unique key when being used as "findOrCreate
" with empty update
field
#21853
Labels
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
kind/bug
A reported bug.
team/client
Issue for team Client.
tech/engines
Issue for tech Engines.
topic: indexes
topic: upsert()
Bug description
Prisma does not seems to hand off upsert correctly when the
update
field is left empty. I instead get aUnique constraint failed on the fields (Username, password)
database error.How to reproduce
When using a compound index primary key like this:
@@id([username, password])
And doing an upsert like this:
Expected behavior
Upsert is correctly acting as findOrCreate method for looking up the user.
Workaround:
We can workaround this issue by providing an arbitrary field inside the update, but ideally it should perform a
DO NOTHING
when the update field is empty. Took me a while to figure out this issue, which ultimately led me to #18883 (comment)Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: