Skip to content

[Bug] Can't not update row with upsert() methond when conflict key is primary key #11556

@acho-0

Description

@acho-0

Issue description

When using upsert() method with 'id'(primary key), row is not updated. upsert() make new row with new Id

Expected Behavior

data:

"descriptions": [
        {
            "id": 315,
            "categoryId": 1,
            "template": "업데이트",
            "name": "이용안내",
            "seq": 0
        },
        {
            "id": 316,
            "categoryId": 1,
            "template": "업데이트",
            "name": "이용안내2",
            "seq": 1
        }
    ],

code:

    return await source.upsert(AccommodationDescription, data, {
      conflictPaths: ['id'],
      upsertType: 'primary-key',
    });

result:
Even thogh row with id 315 and 316 already exists, new row created

Actual Behavior

new row created

Steps to reproduce

Use upsert() method with conflictPath : [${primary-key}], upsertType: 'primary-key'

My Environment

Dependency Version
Operating System MacOS 14.2.1
Node.js version v22.17.0
Typescript version 5.8.3
TypeORM version 0.3.20

Additional Context

No response

Relevant Database Driver(s)

  • aurora-mysql
  • aurora-postgres
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • spanner
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions