{"record":{"id":"e7befd816755a146","repo":"n8n-io/n8n","slug":"onupdate-is-not-supported-by-the-current-database","errorCode":null,"errorMessage":"onUpdate is not supported by the current database driver","messagePattern":"onUpdate is not supported by the current database driver","errorType":"exception","errorClass":"TypeORMError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/typeorm/src/query-builder/InsertQueryBuilder.ts","lineNumber":476,"sourceCode":"\t\t\t} else if (this.connection.driver.supportedUpsertTypes.includes('on-duplicate-key-update')) {\n\t\t\t\tif (this.expressionMap.onUpdate) {\n\t\t\t\t\tconst { overwrite, columns } = this.expressionMap.onUpdate;\n\n\t\t\t\t\tif (Array.isArray(overwrite)) {\n\t\t\t\t\t\tquery += ' ON DUPLICATE KEY UPDATE ';\n\t\t\t\t\t\tquery += overwrite\n\t\t\t\t\t\t\t.map((column) => `${this.escape(column)} = VALUES(${this.escape(column)})`)\n\t\t\t\t\t\t\t.join(', ');\n\t\t\t\t\t\tquery += ' ';\n\t\t\t\t\t} else if (Array.isArray(columns)) {\n\t\t\t\t\t\tquery += ' ON DUPLICATE KEY UPDATE ';\n\t\t\t\t\t\tquery += columns.map((column) => `${this.escape(column)} = :${column}`).join(', ');\n\t\t\t\t\t\tquery += ' ';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (this.expressionMap.onUpdate) {\n\t\t\t\t\tthrow new TypeORMError(`onUpdate is not supported by the current database driver`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// add RETURNING expression\n\t\tif (returningExpression && DriverUtils.isPostgresFamily(this.connection.driver)) {\n\t\t\tquery += ` RETURNING ${returningExpression}`;\n\t\t}\n\n\t\treturn query;\n\t}\n\n\t/**\n\t * Gets list of columns where values must be inserted to.\n\t */\n\tprotected getInsertedColumns(): ColumnMetadata[] {\n\t\tif (!this.expressionMap.mainAlias!.hasMetadata) return [];\n","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/typeorm/src/query-builder/InsertQueryBuilder.ts#L458-L494","documentation":"The final else branch of createConflictExpression throws when expressionMap.onUpdate is set but the driver supports neither 'on-conflict-do-update' (Postgres/SQLite family) nor 'on-duplicate-key-update' (MySQL/MariaDB). This means .orUpdate() was called on a driver like Oracle, SAP HANA, or MongoDB that has no upsert primitive TypeORM can emit.","triggerScenarios":"Calling .orUpdate(...) on an InsertQueryBuilder whose connection.driver.supportedUpsertTypes contains neither upsert type. Also triggered when upsertType is not 'primary-key' (which bypasses this block) and the driver lacks any upsert support.","commonSituations":"Running upsert code on Oracle or SAP HANA. CI against SQLite where 'on-conflict-do-update' IS supported but the driver config doesn't advertise it. Using MongoDB driver with relational upsert API.","solutions":["Check dataSource.driver.supportedUpsertTypes before calling .orUpdate(); fall back to a manual select-then-insert/update.","Use repository.save() or an upsert() method that handles driver differences internally.","Switch to a driver that supports upserts (Postgres, MySQL, SQLite) if upsert is essential.","Set upsertType: 'primary-key' only if your driver supports the primary-key conflict path."],"exampleFix":"// before\nawait dataSource.createQueryBuilder()\n  .insert().into(User).values(payload)\n  .orUpdate({ conflict: ['email'], overwrite: ['name'] }) // throws on Oracle\n  .execute();\n\n// after\nconst supportsUpsert = dataSource.driver.supportedUpsertTypes.length > 0;\nif (supportsUpsert) {\n  await dataSource.createQueryBuilder().insert().into(User).values(payload)\n    .orUpdate({ conflict: ['email'], overwrite: ['name'] }).execute();\n} else {\n  await dataSource.getRepository(User).upsert(payload, ['email']);\n}","handlingStrategy":"validation","validationCode":"function driverSupportsUpsert(ds: DataSource): boolean {\n  return ds.driver.supportedUpsertTypes.length > 0;\n}\nif (!driverSupportsUpsert(dataSource)) { /* manual select-then-insert/update */ }","typeGuard":"function driverSupportsUpsert(driver: import('../driver/Driver').Driver): boolean {\n  return driver.supportedUpsertTypes.length > 0;\n}","tryCatchPattern":"try {\n  await qb.insert().into(E).values(v).orUpdate(opts).execute();\n} catch (e) {\n  if (e instanceof TypeORMError && /onUpdate is not supported/.test(e.message)) { /* fallback */ }\n  throw e;\n}","preventionTips":["Check driver.supportedUpsertTypes before calling .orUpdate().","Prefer repository.upsert() which handles driver differences.","Keep a manual upsert fallback for Oracle/SAP/Mongo.","Document supported DBs for every upsert code path."],"tags":["query-builder","insert","upsert","driver-capability"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}