Browse Source

fix(nocodb): bulk delete transaction issue

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
6816749257
  1. 12
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

12
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/BaseModelSqlv2.ts

@ -2203,10 +2203,7 @@ class BaseModelSqlv2 {
ids.map((d) => this.model.mapAliasToColumn(d)) ids.map((d) => this.model.mapAliasToColumn(d))
); );
transaction = await this.dbDriver.transaction();
const deleted = []; const deleted = [];
const deletePkValues = [];
const res = []; const res = [];
for (const d of deleteIds) { for (const d of deleteIds) {
const pkValues = await this._extractPksValues(d); const pkValues = await this._extractPksValues(d);
@ -2214,13 +2211,14 @@ class BaseModelSqlv2 {
// pk not specified - bypass // pk not specified - bypass
continue; continue;
} }
deletePkValues.push(pkValues); deleted.push(await this.readByPk(pkValues));
await transaction(this.tnPath).del().where(d);
res.push(d); res.push(d);
} }
for (const pkValues of deletePkValues) { transaction = await this.dbDriver.transaction();
deleted.push(await this.readByPk(pkValues));
for (const d of res) {
await transaction(this.tnPath).del().where(d);
} }
await transaction.commit(); await transaction.commit();

Loading…
Cancel
Save