From f9e8689ce9cddb14fca5ad18ef142a9f5970ca0e Mon Sep 17 00:00:00 2001 From: Dean Date: Tue, 10 Sep 2024 12:19:41 +0100 Subject: [PATCH] Test fixes for view search --- packages/server/src/api/controllers/row/views.ts | 2 +- packages/shared-core/src/filters.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/server/src/api/controllers/row/views.ts b/packages/server/src/api/controllers/row/views.ts index 220e2098f7..8a1e5e08ce 100644 --- a/packages/server/src/api/controllers/row/views.ts +++ b/packages/server/src/api/controllers/row/views.ts @@ -36,7 +36,7 @@ export async function searchView( // Enrich saved query with ephemeral query params. // We prevent searching on any fields that are saved as part of the query, as // that could let users find rows they should not be allowed to access. - let query: any = dataFilters.buildQuery(view.query ?? []) + let query: any = dataFilters.buildQuery(view.query) if (body.query) { // Delete extraneous search params that cannot be overridden delete body.query.onEmptyFilter diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 4bb3a6a7df..79c95380e2 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -428,7 +428,11 @@ const builderFilter = (expression: SearchFilter) => { return query } -export const buildQuery = (filter: SearchFilterGroup | SearchFilter[]) => { +export const buildQuery = (filter?: SearchFilterGroup | SearchFilter[]) => { + if (!filter) { + return + } + const parsedFilter = processSearchFilters(filter) if (!parsedFilter) {