-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue description
When using .onUpdate, the SQL is not being composed correctly.
Expected Behavior
INSERT INTO "product_category" AS "ProductCategory"("_id", "name") VALUES ($1, $2), ... ON CONFLICT ( "_id" ) DO UPDATE SET "name" = EXCLUDED."name" WHERE ("ProductCategory"."name" IS DISTINCT FROM EXCLUDED."name") RETURNING "id"
Actual Behavior
QueryFailedError: invalid reference to FROM-clause entry for table "product_category"
INSERT INTO "product_category" AS "ProductCategory"("_id", "name") VALUES ($1, $2), ... ON CONFLICT ( "_id" ) DO UPDATE SET "name" = EXCLUDED."name" WHERE ("product_category"."name" IS DISTINCT FROM EXCLUDED."name") RETURNING "id"
Steps to reproduce
await this.productCategoryRepo
.createQueryBuilder()
.insert()
.values(
categories.map((category) => ({
_id: category.id,
name: category.name,
})),
)
.orUpdate(
['name'],
['_id'],
{
skipUpdateIfNoValuesChanged: true,
}
)
.execute();
My Environment
| Dependency | Version |
|---|---|
| Operating System | LINUX |
| Node.js version | 20.17.0 |
| Typescript version | 5.6.2 |
| 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?
Yes, I have the time, but I don't know how to start. I would need guidance.