Skip to content

Commit 926f318

Browse files
committed
feat: enhance data filtering by adding primary key check in visibility logic
1 parent 07ffa98 commit 926f318

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

adminforth/modules/restApi.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,16 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
840840
})
841841
);
842842

843+
const pkField = resource.columns.find((col) => col.primaryKey)?.name;
843844
// remove all columns which are not defined in resources, or defined but backendOnly
844845
data.data.forEach((item) => {
845846
Object.keys(item).forEach((key) => {
846-
console.log(visibleColumns?.[key], key);
847-
if (!resource.columns.find((col) => col.name === key) || resource.columns.find((col) => col.name === key && col.backendOnly) || visibleColumns?.[key] === false ) {
847+
const isPk = pkField && key === pkField;
848+
const isUnknown = !resource.columns.find((col) => col.name === key);
849+
const isBackendOnly = resource.columns.find((col) => col.name === key && col.backendOnly);
850+
const isHiddenByACL = visibleColumns?.[key] === false;
851+
852+
if (isUnknown || isBackendOnly || (isHiddenByACL && !isPk)) {
848853
delete item[key];
849854
}
850855
})

0 commit comments

Comments
 (0)