From 3aafbca10fd8aee3a962c111bab90f7b0f410f57 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Fri, 11 Oct 2024 16:17:46 +0000 Subject: [PATCH] fix: update use of transaction --- packages/nocodb/src/db/BaseModelSqlv2.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/nocodb/src/db/BaseModelSqlv2.ts b/packages/nocodb/src/db/BaseModelSqlv2.ts index eb36915117..759829556e 100644 --- a/packages/nocodb/src/db/BaseModelSqlv2.ts +++ b/packages/nocodb/src/db/BaseModelSqlv2.ts @@ -5482,7 +5482,7 @@ class BaseModelSqlv2 { } if ('beforeBulkInsert' in this) { - await this.beforeBulkInsert(insertDatas, trx, cookie); + await this.beforeBulkInsert(insertDatas, transaction, cookie); } // await this.beforeInsertb(insertDatas, null); @@ -5574,7 +5574,7 @@ class BaseModelSqlv2 { await this.runOps( postInsertOps.map((f) => f(rowId)), - trx, + transaction, ); } @@ -5593,7 +5593,8 @@ class BaseModelSqlv2 { return responses; } catch (e) { - await transaction?.rollback(); + if (!trx) await transaction?.rollback(); + // await this.errorInsertb(e, data, null); throw e; } @@ -5849,7 +5850,7 @@ class BaseModelSqlv2 { return newData; } catch (e) { - if (transaction) await transaction.rollback(); + if (!trx) await transaction.rollback(); throw e; } }