From 062df0ff8b0711416bb82c26708ec512fc7501d4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 15 May 2024 11:01:36 +0200 Subject: [PATCH] Cleanup --- packages/server/src/sdk/app/rows/search.ts | 4 +--- .../server/src/sdk/app/rows/search/utils.ts | 22 +++++-------------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/packages/server/src/sdk/app/rows/search.ts b/packages/server/src/sdk/app/rows/search.ts index 69ded8e76f..e347a8657d 100644 --- a/packages/server/src/sdk/app/rows/search.ts +++ b/packages/server/src/sdk/app/rows/search.ts @@ -79,9 +79,7 @@ export async function search( } const table = await sdk.tables.getTable(options.tableId) - options = searchInputMapping(table, options, { - isSql: !!table.sql, - }) + options = searchInputMapping(table, options) if (isExternalTable) { return external.search(options, table) diff --git a/packages/server/src/sdk/app/rows/search/utils.ts b/packages/server/src/sdk/app/rows/search/utils.ts index bae45298eb..cf4a4e61c6 100644 --- a/packages/server/src/sdk/app/rows/search/utils.ts +++ b/packages/server/src/sdk/app/rows/search/utils.ts @@ -52,8 +52,7 @@ function findColumnInQueries( function userColumnMapping( column: string, options: RowSearchParams, - isDeprecatedSingleUserColumn: boolean = false, - isSql: boolean = false + isDeprecatedSingleUserColumn: boolean = false ) { findColumnInQueries(column, options, (filterValue: any): any => { const isArray = Array.isArray(filterValue), @@ -71,33 +70,23 @@ function userColumnMapping( } } - let wrapper = (s: string) => s - if (isDeprecatedSingleUserColumn && filterValue && isSql) { - // Deprecated single users are stored as stringified arrays of a single value - wrapper = (s: string) => JSON.stringify([s]) - } - if (isArray) { return filterValue.map(el => { if (typeof el === "string") { - return wrapper(processString(el)) + return processString(el) } else { return el } }) } else { - return wrapper(processString(filterValue)) + return processString(filterValue) } }) } // maps through the search parameters to check if any of the inputs are invalid // based on the table schema, converts them to something that is valid. -export function searchInputMapping( - table: Table, - options: RowSearchParams, - datasourceOptions: { isSql?: boolean } = {} -) { +export function searchInputMapping(table: Table, options: RowSearchParams) { if (!table?.schema) { return options } @@ -119,8 +108,7 @@ export function searchInputMapping( userColumnMapping( key, options, - helpers.schema.isDeprecatedSingleUserColumn(column), - datasourceOptions.isSql + helpers.schema.isDeprecatedSingleUserColumn(column) ) break }