Open oriuken opened 2 years ago
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. đŸ™‚
Still not working
Bug Description
When using
upsert
(with Postgres) with a model that has a composite unique index, a Validation Error is being thrown since the query is using the model primary key on "ON CONFLICT" instead of the composite unique index.Here are some code examples
Model Definition:
Migration file:
Service code (where we actually make the call):
I can also confirm that in Postgres database, an index was created for the composite unique index by the following query:
The Issue
The previous
upsert
call is throwing the next error when there is already a record with subjectId and objectId:And the SQL query that is being run is as follows:
What do you expect to happen?
"subject_id"
and"object_id"
at "ON CONFLICT" instead of"id"
like shown below:This last query I tried it on Postgres directly using
"subject_id"
and"object_id"
at "ON CONFLICT" instead of"id"
and the record was successfully updated !What is actually happening?
The previous
upsert
call is throwing the next error:Validation error {"message":"Validation error","name":"SequelizeUniqueConstraintError"...
And the SQL query that is being run is as follows:
Environment