Skip to content

Commit 8c21a4b

Browse files
committed
fix: add check, is sort column really exists
AdminForth/1810/we-should-handle-incorrect-fie
1 parent 5a4a04a commit 8c21a4b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

adminforth/modules/restApi.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1420,8 +1420,10 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
14201420
: undefined;
14211421

14221422
// remove virtual fields from sort if still presented after beforeDatasourceRequest hook
1423+
// and drop sort items referencing columns that don't exist in resource config
14231424
const sortFiltered = (sort || []).filter((sortItem: IAdminForthSort) => {
1424-
return !resource.columns.find((col) => col.name === sortItem.field && col.virtual);
1425+
const col = resource.columns.find((col) => col.name === sortItem.field);
1426+
return col && !col.virtual;
14251427
});
14261428

14271429
// after beforeDatasourceRequest hook, filter can be anything

0 commit comments

Comments
 (0)