From 53af94f971ba03d6ba2568dc7328b24e21329c6f Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Tue, 2 Jul 2024 14:02:16 +0200 Subject: [PATCH] Fix search returning non visible columns --- packages/server/src/api/controllers/row/views.ts | 4 +++- packages/server/src/api/routes/tests/viewV2.spec.ts | 13 +++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index 63ce12f0ab..12e76155bc 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -25,7 +25,9 @@ export async function searchView( ctx.throw(400, `This method only supports viewsV2`) } - const viewFields = Object.keys(view.schema || {}) + const viewFields = Object.entries(view.schema || {}) + .filter(([_, value]) => value.visible) + .map(([key]) => key) const { body } = ctx.request // Enrich saved query with ephemeral query params. diff --git a/packages/server/src/api/routes/tests/viewV2.spec.ts b/packages/server/src/api/routes/tests/viewV2.spec.ts index 5d83cd8616..43a6d39172 100644 --- a/packages/server/src/api/routes/tests/viewV2.spec.ts +++ b/packages/server/src/api/routes/tests/viewV2.spec.ts @@ -879,14 +879,14 @@ describe.each([ view = await config.api.viewV2.get(view.id) await config.api.viewV2.update( { - ...view, - schema: { - ...view.schema, - Price: { - visible: false, + ...view, + schema: { + ...view.schema, + Price: { + visible: false, + }, }, }, - }, { status: 400, body: { @@ -1201,6 +1201,7 @@ describe.each([ ], schema: { id: { visible: true }, + one: { visible: false }, two: { visible: true }, }, })