Browse Source

fix: validate params in list api

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/6770/head
Pranav C 1 year ago
parent
commit
4dae512161
  1. 21
      packages/nocodb/src/db/BaseModelSqlv2.ts
  2. 2
      packages/nocodb/src/services/datas.service.ts

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

@ -271,6 +271,7 @@ class BaseModelSqlv2 {
} = {},
ignoreViewFilterAndSort = false,
validateFormula = false,
throwErrorIfInvalidParams = false,
): Promise<any> {
const { where, fields, ...rest } = this._getListArgs(args as any);
@ -287,8 +288,16 @@ class BaseModelSqlv2 {
}
const aliasColObjMap = await this.model.getAliasColObjMap();
let sorts = extractSortsObject(rest?.sort, aliasColObjMap);
const filterObj = extractFilterFromXwhere(where, aliasColObjMap);
let sorts = extractSortsObject(
rest?.sort,
aliasColObjMap,
throwErrorIfInvalidParams,
);
const filterObj = extractFilterFromXwhere(
where,
aliasColObjMap,
throwErrorIfInvalidParams,
);
// todo: replace with view id
if (!ignoreViewFilterAndSort && this.viewId) {
await conditionV2(
@ -311,6 +320,8 @@ class BaseModelSqlv2 {
}),
],
qb,
undefined,
throwErrorIfInvalidParams,
);
if (!sorts)
@ -318,7 +329,7 @@ class BaseModelSqlv2 {
? args.sortArr
: await Sort.list({ viewId: this.viewId });
await sortV2(this, sorts, qb);
await sortV2(this, sorts, qb, undefined, throwErrorIfInvalidParams);
} else {
await conditionV2(
this,
@ -335,11 +346,13 @@ class BaseModelSqlv2 {
}),
],
qb,
undefined,
throwErrorIfInvalidParams,
);
if (!sorts) sorts = args.sortArr;
await sortV2(this, sorts, qb);
await sortV2(this, sorts, qb, undefined, throwErrorIfInvalidParams);
}
// sort by primary key if not autogenerated string

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

@ -169,7 +169,7 @@ export class DatasService {
try {
data = await nocoExecute(
ast,
await baseModel.list(listArgs),
await baseModel.list(listArgs, false, false, throwErrorIfInvalidParams),
{},
listArgs,
);

Loading…
Cancel
Save