New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
upsert
on compound primary key should do ON CONFLICT DO ...
in postgresql
#18883
Comments
Hey @futpib, thanks for opening an issue. When did Prisma try to execute the query you shared with us - on the |
I quickly tried to reproduce this. I manually (via
It executes this SQL:
This works in both the What am I missing? |
@janpio i just ran across this same issue. I actually tried to reduce the reproducible test case by using a single unique column, but it still doesn't generate the native query. Is there something I'm missing? Does this require a specific Postgres version to use I'm using Prisma client 4.15.0. Postgres version is 14.7. Pretty baffled by this. |
I may have just figured this out, at least for my specific case. It appears that when using @janpio thoughts? i can open a new ticket for this if this is valid. |
I've come across this issue as well @calvinl - would love to see this get worked on. |
@janpio I'll open a ticket now, thanks for the response! @ahammouda -- I was able to get around this by just putting a field in the |
👋 @futpib, Have you had a chance to read the other comments in this issue? Could you confirm that the suggestions resolve your issue? We would appreciate your input to help us resolve this issue if it's a bug. |
Hi @calvinl , which ticket did you create for this? updating an arbitrary field is a solid workaround but I had to go through a lot of reading before I stumbled upon this issue to solve it on my end. |
@DRoet oops, I never opened one. I ended up switching off of prisma to kysely shortly after this. Feel free to open one though! |
Can you turn this into a standalone issue please @AllanOricil? As you can see in the messages above, you might not be the first one - so we should look into this. Thanks! |
Bug description
When using a compound primary key like this:
@@id([referrerEventId, refereeEventId])
And doing an upsert like this:
Postgres receices SQL update query without an
on conflict
:Which results in the following exception being thrown:
This defies the purpose of
upsert
.Related: #9972
How to reproduce
Description is basically a reproduction.
Expected behavior
Prisma generates a proper upsert SQL with an
ON CONFLICT
clause handing the conflict.Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: