You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Upsert does not respect the update: false option of generated columns (or maybe all columns?).
Expected Behavior
I have this generated column;
@Column({
type: 'boolean',
generatedType: 'STORED',
update: false,
insert: false,
asExpression: `keepalive IS NOT NULL`,
nullable: false,
})
inProgress: boolean;
I'm trying to upsert a record using the following code;
await Record.getRepository().upsert({ foo: 1, bar: 2 }}, ['foo', 'bar', 'inProgress']);
Even though inProgress is used as part of the ON CONFLICT clause, I wouldn't expect it to be updated. Yet, I get this error.
Error [QueryFailedError]: column "in_progress" can only be updated to DEFAULT
at PostgresQueryRunner.query (/Users/christianblais/Code/github.com/unitoio/sync-services/services/scanner-worker/node_modules/typeorm/driver/src/driver/postgres/PostgresQueryRunner.ts:331:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at InsertQueryBuilder.execute (/Users/christianblais/Code/github.com/unitoio/sync-services/services/scanner-worker/node_modules/typeorm/query-builder/src/query-builder/InsertQueryBuilder.ts:163:33)
[...]
at async Test.run (node:internal/test_runner/test:632:9)
at async Suite.processPendingSubtests (node:internal/test_runner/test:374:7) {
query: 'INSERT INTO "public"."table"("foo", "bar" VALUES ($1, $2) ON CONFLICT ( "foo", "bar", "in_progress" ) DO UPDATE SET "foo" = EXCLUDED."foo", "bar" = EXCLUDED."bar", "in_progress" = EXCLUDED."in_progress", "keepalive" = EXCLUDED."keepalive" RETURNING "foo", "bar", "keepalive", "in_progress"',
parameters: [ '1', '2'],
driverError: error: column "in_progress" can only be updated to DEFAULT
As you can see, the DO UPDATE SET still tries to update the generated column, even though it is 1) generated and 2) flagged as update: false.
Actual Behavior
I would have expected the DO UPDATE SET to not include generated columns, nor any other column with update: false.
Steps to reproduce
I don't have reproducible steps at hand.
My Environment
Dependency
Version
Operating System
Node.js version
20.11.1
Typescript version
5.4
TypeORM version
0.3.20
Additional Context
No additional context.
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.
The text was updated successfully, but these errors were encountered:
Issue description
Upsert does not respect the
update: false
option of generated columns (or maybe all columns?).Expected Behavior
I have this generated column;
I'm trying to upsert a record using the following code;
Even though
inProgress
is used as part of the ON CONFLICT clause, I wouldn't expect it to be updated. Yet, I get this error.As you can see, the DO UPDATE SET still tries to update the generated column, even though it is 1) generated and 2) flagged as
update: false
.Actual Behavior
I would have expected the DO UPDATE SET to not include generated columns, nor any other column with
update: false
.Steps to reproduce
I don't have reproducible steps at hand.
My Environment
Additional Context
No additional context.
Relevant Database Driver(s)
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.
The text was updated successfully, but these errors were encountered: