Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

meta query cannot have transaction

Fendy Heryanto73d0c7fa18ae
diff --git a/packages/nocodb/src/db/BaseModelSqlv2/delete.ts b/packages/nocodb/src/db/BaseModelSqlv2/delete.ts
index 342cd4c470..791d891aec 100644
--- a/packages/nocodb/src/db/BaseModelSqlv2/delete.ts
+++ b/packages/nocodb/src/db/BaseModelSqlv2/delete.ts
@@ -1,19 +1,18 @@
+import { Logger } from '@nestjs/common';
import {
AuditV1OperationTypes,
extractFilterFromXwhere,
isLinksOrLTAR,
UITypes,
} from 'nocodb-sdk';
-import { Logger } from '@nestjs/common';
-import type CustomKnex from '~/db/CustomKnex';
import type { Knex } from 'knex';
import type { NcRequest } from 'nocodb-sdk';
+import type CustomKnex from '~/db/CustomKnex';
import type { IBaseModelSqlV2 } from '~/db/IBaseModelSqlV2';
import type { LinkToAnotherRecordColumn } from '~/models';
-import conditionV2 from '~/db/conditionV2';
import { _wherePk } from '~/helpers/dbHelpers';
+import conditionV2 from '~/db/conditionV2';
import { Column, FileReference, Filter, Model } from '~/models';
-import Noco from '~/Noco';
export type ExecQueryType = (param: {
trx: Knex.Transaction | CustomKnex;
@@ -23,7 +22,6 @@ export type ExecQueryType = (param: {
}) => any[];
export type MetaQueryType = (param: {
- trx: Knex.Transaction;
qb: any;
ids: any[];
rows: any[];
@@ -166,7 +164,7 @@ export class BaseModelDelete {
(c) => c.uidt === UITypes.Attachment,
);
- metaQueries.push(async ({ trx, rows }) => {
+ metaQueries.push(async ({ rows }) => {
const fileReferenceIds: string[] = [];
for (const row of rows) {
for (const c of attachmentColumns) {
@@ -195,11 +193,7 @@ export class BaseModelDelete {
}
}
}
- await FileReference.delete(
- this.baseModel.context,
- fileReferenceIds,
- Noco.ncMeta.withTransaction(trx),
- );
+ await FileReference.delete(this.baseModel.context, fileReferenceIds);
});
// delete the rows in table
@@ -247,9 +241,6 @@ export class BaseModelDelete {
for (const execQuery of execQueries) {
await execQuery({ trx, qb: qb.clone(), ids, rows });
}
- for (const metaQuery of metaQueries) {
- await metaQuery({ trx, qb: qb.clone(), ids, rows });
- }
await trx.commit();
response.push(...rows);
} catch (ex) {
@@ -257,6 +248,9 @@ export class BaseModelDelete {
// silent error, may be improved to log into response
this.logger.error(ex.message);
}
+ for (const metaQuery of metaQueries) {
+ await metaQuery({ qb: qb.clone(), ids, rows });
+ }
return response;
}
diff --git a/packages/nocodb/src/meta/meta.service.ts b/packages/nocodb/src/meta/meta.service.ts
index c23c0bccda..83cdea56ed 100644
--- a/packages/nocodb/src/meta/meta.service.ts
+++ b/packages/nocodb/src/meta/meta.service.ts
@@ -745,15 +745,6 @@ export class MetaService {
return new MetaService(this.config, trx);
}
- withTransaction(trx: Knex.Transaction<any, any[]>) {
- // todo: Extend transaction class to add our custom properties
- Object.assign(trx, {
- clientType: this.connection.clientType,
- searchPath: (this.connection as any).searchPath,
- });
- return new MetaService(this.config, trx);
- }
-
/***
* Update base config
* @param baseId - Base id