-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue description
When using the upsert method with skipUpdateIfNoValuesChanged, the query uses the correct "schemaName"."tableName" format initially but switches to "schemaName.tableName" after the WHERE clause, causing the query to fail. Expected Behavior
Expected Behavior
The upsert method should generate a query that consistently uses the correct schema and table name format throughout the query. For example:
INSERT INTO "schema"."table" ("id", "name")
VALUES ($1, $2)
ON CONFLICT ("id") DO UPDATE
SET "name" = EXCLUDED."name"
WHERE "schema"."table"."name" IS DISTINCT FROM EXCLUDED."name";Actual Behavior
The query generated by the upsert method starts with the correct schema and table name format but switches to an incorrect format after the WHERE clause. For example:
INSERT INTO "schema"."table" ("id", "name")
VALUES ($1, $2)
ON CONFLICT ("id") DO UPDATE
SET "name" = EXCLUDED."name"
WHERE "schema.table"."name" IS DISTINCT FROM EXCLUDED."name";Steps to reproduce
Create a simple entity:
@Entity({ schema: "test", name: "example" })
export class Example {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
}Use the upsert method:
const example = new Example () as DeepPartial<Example>;
await repository.upsert(example, {
conflictPaths: {"id": true},
skipUpdateIfNoValuesChanged: true
});My Environment
| Dependency | Version |
|---|---|
| Operating System | Windows |
| Node.js | 20.12.2 |
| Typescript | 5.8.3 |
| TypeORM | 0.3.24 |
| NestJS | 11.1.1 |
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, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.
Vilican and omBratteng