Browse Source

fix(nocodb): revise bulk delete logic

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

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

@ -2058,17 +2058,24 @@ class BaseModelSqlv2 {
transaction = await this.dbDriver.transaction(); transaction = await this.dbDriver.transaction();
const deleted = [];
const res = []; const res = [];
for (const d of deleteIds) { for (const d of deleteIds) {
if (Object.keys(d).length) { await this.validate(d);
const pkValues = await this._extractPksValues(d);
if (!pkValues) {
// pk not specified - bypass
continue;
}
deleted.push(await this.readByPk(pkValues));
await transaction(this.tnPath).del().where(d); await transaction(this.tnPath).del().where(d);
res.push(d); res.push(d);
} }
}
transaction.commit(); transaction.commit();
await this.afterBulkDelete(res, this.dbDriver, cookie); await this.afterBulkDelete(deleted, this.dbDriver, cookie);
return res; return res;
} catch (e) { } catch (e) {

Loading…
Cancel
Save