Skip to content

Upsert code fails with composite unique key #5351

@antoineDeRengerve

Description

@antoineDeRengerve

(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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugDEPRECATED: replace with the "bug" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions