Database upsert with composite unique constraint #24888
Replies: 3 comments 1 reply
|
Hi @valentinpollart 👋 Your interpretation of upsert is correct. The constraint Is that the same error message that is being thrown? I tried the |
|
My bad, I meant the P2002: Unique constraint error. |
|
Hi there, To keep our discussions organized and focused on the most relevant topics, we’re reviewing and tidying up our backlog. As part of this process, we’re closing discussions that haven’t had any recent activity and appear to be outdated. If this discussion is still important to you or unresolved, we’d love to hear from you! Feel free to reopen it or start a new one with updated details. For more details about our priorities and vision for the future of Prisma ORM, check out our latest blog post: https://www.prisma.io/blog/prisma-orm-manifesto. Thank you for your understanding and being part of the community!; |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Question
Hello,
I'm not sure to interpret properly the documentation regarding database upsert. I do have a situation similar to the one described as example in the situation :
However, for my upsert query, I'd need to use a where clause on the unique constraint id_profileViews as follows :
Does it counts as one unique field in where clause towards the fourth database upsert query criteria specified in the docs? If so, is there a specific way to use the same field in the create clause to respect the fifth criteria? In my case, it seems it doesn't work (I get P2022 error, which is not supposed to happen with database upsert). I made sure the three other criterion are respected as well as the prerequisites in terms of Prisma version and database engine.
How to reproduce (optional)
No response
Expected behavior (optional)
No response
Information about Prisma Schema, Client Queries and Environment (optional)
No response
All reactions