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 code fails with composite unique key #5351

Closed
antoineDeRengerve opened this Issue Feb 2, 2016 · 0 comments

Comments

2 participants
@antoineDeRengerve

antoineDeRengerve commented Feb 2, 2016

(Maybe related to #4776)
Upserts work correctly when there are unique indexes for only one value not with composite unique keys.

I defined in sequelize : (in an option of orm.define)

            indexes:[
                {
                    type: "unique",
                    fields: ['PartId', 'code'],
                    name: "StEvt_partCode"
                }

The operation fails with :

ERROR:  duplicate key value violates unique constraint "StEvt_partCode"
DETAIL:  Key ("PartId", code)=(1, 0) already exists.
CONTEXT:  SQL statement "UPDATE "StatusEvts" SET "PartId"=1,"code"=0,"msg"='Normal'"
PL/pgSQL function pg_temp_2.sequelize_upsert() line 1 at SQL statement

And the composite unique key is not explained in a where option of the UPDATE part of the query.

@janmeier janmeier added the bug label Feb 21, 2016

@janmeier janmeier closed this in 7764212 Feb 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment