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

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

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

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

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

Loading…
Cancel
Save