Browse Source

fix: skip validation and hooks when updating column options

pull/7070/head
Pranav C 1 year ago
parent
commit
b0d0a6fbea
  1. 14
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 5
      packages/nocodb/src/services/columns.service.ts

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

@ -3210,7 +3210,12 @@ class BaseModelSqlv2 {
}
async bulkUpdateAll(
args: { where?: string; filterArr?: Filter[]; viewId?: string } = {},
args: {
where?: string;
filterArr?: Filter[];
viewId?: string;
skipValidationAndHooks?: boolean;
} = {},
data,
{ cookie }: { cookie?: any } = {},
) {
@ -3221,7 +3226,7 @@ class BaseModelSqlv2 {
this.clientMeta,
this.dbDriver,
);
await this.validate(updateData);
if (!args.skipValidationAndHooks) await this.validate(updateData);
const pkValues = await this._extractPksValues(updateData);
if (pkValues) {
// pk is specified - by pass
@ -3255,7 +3260,7 @@ class BaseModelSqlv2 {
);
}
await conditionV2(this, conditionObj, qb);
await conditionV2(this, conditionObj, qb, undefined, true);
count = (
await this.execAndParse(
@ -3273,7 +3278,8 @@ class BaseModelSqlv2 {
await this.execAndParse(qb, null, { raw: true });
}
await this.afterBulkUpdate(null, count, this.dbDriver, cookie, true);
if (!args.skipValidationAndHooks)
await this.afterBulkUpdate(null, count, this.dbDriver, cookie, true);
return count;
} catch (e) {

5
packages/nocodb/src/services/columns.service.ts

@ -546,7 +546,10 @@ export class ColumnsService {
]);
} else {
await baseModel.bulkUpdateAll(
{ where: `(${column.title},eq,${option.title})` },
{
where: `(${column.title},eq,${option.title})`,
skipValidationAndHooks: true,
},
{ [column.column_name]: null },
{ cookie },
);

Loading…
Cancel
Save