Browse Source

fix: options object for list

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/6953/head
mertmit 1 year ago
parent
commit
37ba072ded
  1. 25
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 8
      packages/nocodb/src/services/datas.service.ts
  3. 2
      packages/nocodb/tests/unit/factory/row.ts

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

@ -265,10 +265,20 @@ class BaseModelSqlv2 {
sort?: string | string[]; sort?: string | string[];
fieldsSet?: Set<string>; fieldsSet?: Set<string>;
} = {}, } = {},
options: {
ignoreViewFilterAndSort?: boolean;
ignorePagination?: boolean;
validateFormula?: boolean;
throwErrorIfInvalidParams?: boolean;
} = {},
): Promise<any> {
const {
ignoreViewFilterAndSort = false, ignoreViewFilterAndSort = false,
ignorePagination = false,
validateFormula = false, validateFormula = false,
throwErrorIfInvalidParams = false, throwErrorIfInvalidParams = false,
): Promise<any> { } = options;
const { where, fields, ...rest } = this._getListArgs(args as any); const { where, fields, ...rest } = this._getListArgs(args as any);
const qb = this.dbDriver(this.tnPath); const qb = this.dbDriver(this.tnPath);
@ -359,7 +369,7 @@ class BaseModelSqlv2 {
qb.orderBy('created_at'); qb.orderBy('created_at');
} }
applyPaginate(qb, rest); if (!ignorePagination) applyPaginate(qb, rest);
const proto = await this.getProto(); const proto = await this.getProto();
let data; let data;
@ -370,7 +380,11 @@ class BaseModelSqlv2 {
if (validateFormula || !haveFormulaColumn(await this.model.getColumns())) if (validateFormula || !haveFormulaColumn(await this.model.getColumns()))
throw e; throw e;
console.log(e); console.log(e);
return this.list(args, ignoreViewFilterAndSort, true); return this.list(args, {
ignoreViewFilterAndSort,
ignorePagination,
validateFormula: true,
});
} }
return data?.map((d) => { return data?.map((d) => {
d.__proto__ = proto; d.__proto__ = proto;
@ -1891,7 +1905,10 @@ class BaseModelSqlv2 {
}), }),
], ],
}, },
true, {
ignoreViewFilterAndSort: true,
ignorePagination: true,
},
); );
const groupedList = groupBy(data, pCol.title); const groupedList = groupBy(data, pCol.title);

8
packages/nocodb/src/services/datas.service.ts

@ -170,12 +170,10 @@ export class DatasService {
try { try {
data = await nocoExecute( data = await nocoExecute(
ast, ast,
await baseModel.list( await baseModel.list(listArgs, {
listArgs,
ignoreViewFilterAndSort, ignoreViewFilterAndSort,
false, throwErrorIfInvalidParams: param.throwErrorIfInvalidParams,
param.throwErrorIfInvalidParams, }),
),
{}, {},
listArgs, listArgs,
); );

2
packages/nocodb/tests/unit/factory/row.ts

@ -232,7 +232,7 @@ const listRow = async ({
const ignorePagination = !options; const ignorePagination = !options;
return await baseModel.list(options, ignorePagination); return await baseModel.list(options, { ignorePagination });
}; };
const getOneRow = async ( const getOneRow = async (

Loading…
Cancel
Save