-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Description
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.