Browse Source

fix: skip validation and hooks when updating column options

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

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

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

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

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

Loading…
Cancel
Save