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

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

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

Loading…
Cancel
Save