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

Loading…
Cancel
Save