error: there is no unique or exclusion constraint matching the ON CONFLICT specification
Hello, I'm facing a problem with the insert on the table when I use the
onConflictDoUpdate
with targets that are not the primary key.
Check the table below:
And I want to upsert the product with:
Note: The product
is a object with a random id
that will not be present in DB, so I can't compare the id's, otherwise I'll end up with duplicate products in the table.5 Replies
A workaround would be make those columns a unique index
UNIQUE
or UNIQUE INDEX
? What is the best option on this case?It has to be unique, otherwise it won't trigger the conflict when you'r trying to insert the same values
Seems that the
UNIQUE
don't fix the problem.
Table:
The error:
I don't think this was resolved? I'm hitting the same issues