Browse Source

fix: rollback transaction if bulk insert errors

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5743/head
Raju Udava 1 year ago
parent
commit
89fdf3d833
  1. 4
      packages/nocodb/src/db/BaseModelSqlv2.ts

4
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -2091,6 +2091,7 @@ class BaseModelSqlv2 {
raw?: boolean; raw?: boolean;
} = {}, } = {},
) { ) {
let trx;
try { try {
// TODO: ag column handling for raw bulk insert // TODO: ag column handling for raw bulk insert
const insertDatas = raw const insertDatas = raw
@ -2115,7 +2116,7 @@ class BaseModelSqlv2 {
// refer : https://www.sqlite.org/limits.html // refer : https://www.sqlite.org/limits.html
const chunkSize = this.isSqlite ? 10 : _chunkSize; const chunkSize = this.isSqlite ? 10 : _chunkSize;
const trx = await this.dbDriver.transaction(); trx = await this.dbDriver.transaction();
if (!foreign_key_checks) { if (!foreign_key_checks) {
if (this.isPg) { if (this.isPg) {
@ -2146,6 +2147,7 @@ class BaseModelSqlv2 {
return response; return response;
} catch (e) { } catch (e) {
await trx?.rollback();
// await this.errorInsertb(e, data, null); // await this.errorInsertb(e, data, null);
throw e; throw e;
} }

Loading…
Cancel
Save