Skip to content

upsert on error on UpdateDateColumn with some dbs #10587

@alenap93

Description

@alenap93

Issue description

upsert operations goes on error with UpdateDateColumn with some dbs

Expected Behavior

Upsert operations on entity that have a column with decorator UpdateDateColumn has to pass without errors on all dbs.

Actual Behavior

Test repository > basic methods - upsert - should first create then update an entity inside repository-basic-methods.ts goes on error, it tries to upsert on entity with a column with UpdateDateColumn decorator, and for insert create this query:
INSERT INTO "post"("id", "eXtErNal___id", "title", "subTitle", "dateAdded", "createdAt", "uPdAtEd___At", "categoryId") VALUES (NULL, ?, ?, NULL, NULL, datetime('now'), datetime('now'), NULL) ON CONFLICT ( "eXtErNal___id" ) DO UPDATE SET "eXtErNal___id" = EXCLUDED."eXtErNal___id", "title" = EXCLUDED."title", "uPdAtEd___At" = DEFAULT

The bolder part is the error cause, only with some dbs.

Steps to reproduce

run test repository > basic methods - upsert - should first create then update an entity inside repository-basic-methods.ts

My Environment

Dependency Version
Operating System Windows 11
Node.js version 16
Typescript version 4.9.5
TypeORM version 0.3.17

Additional Context

fix can be made setting that bolder part only (like other code parts) if this condition doesn't match:

  !(
      (this.connection.driver.options
          .type === "oracle" &&
          this.getValueSets().length >
              1) ||
      DriverUtils.isSQLiteFamily(
          this.connection.driver,
      ) ||
      this.connection.driver.options
          .type === "sap" ||
      this.connection.driver.options
          .type === "spanner"
  )

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?

Yes, I have the time, and I know how to start.

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