Cleanup
This commit is contained in:
parent
25d86d179d
commit
062df0ff8b
|
@ -79,9 +79,7 @@ export async function search(
|
||||||
}
|
}
|
||||||
|
|
||||||
const table = await sdk.tables.getTable(options.tableId)
|
const table = await sdk.tables.getTable(options.tableId)
|
||||||
options = searchInputMapping(table, options, {
|
options = searchInputMapping(table, options)
|
||||||
isSql: !!table.sql,
|
|
||||||
})
|
|
||||||
|
|
||||||
if (isExternalTable) {
|
if (isExternalTable) {
|
||||||
return external.search(options, table)
|
return external.search(options, table)
|
||||||
|
|
|
@ -52,8 +52,7 @@ function findColumnInQueries(
|
||||||
function userColumnMapping(
|
function userColumnMapping(
|
||||||
column: string,
|
column: string,
|
||||||
options: RowSearchParams,
|
options: RowSearchParams,
|
||||||
isDeprecatedSingleUserColumn: boolean = false,
|
isDeprecatedSingleUserColumn: boolean = false
|
||||||
isSql: boolean = false
|
|
||||||
) {
|
) {
|
||||||
findColumnInQueries(column, options, (filterValue: any): any => {
|
findColumnInQueries(column, options, (filterValue: any): any => {
|
||||||
const isArray = Array.isArray(filterValue),
|
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) {
|
if (isArray) {
|
||||||
return filterValue.map(el => {
|
return filterValue.map(el => {
|
||||||
if (typeof el === "string") {
|
if (typeof el === "string") {
|
||||||
return wrapper(processString(el))
|
return processString(el)
|
||||||
} else {
|
} else {
|
||||||
return el
|
return el
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
return wrapper(processString(filterValue))
|
return processString(filterValue)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// maps through the search parameters to check if any of the inputs are invalid
|
// 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.
|
// based on the table schema, converts them to something that is valid.
|
||||||
export function searchInputMapping(
|
export function searchInputMapping(table: Table, options: RowSearchParams) {
|
||||||
table: Table,
|
|
||||||
options: RowSearchParams,
|
|
||||||
datasourceOptions: { isSql?: boolean } = {}
|
|
||||||
) {
|
|
||||||
if (!table?.schema) {
|
if (!table?.schema) {
|
||||||
return options
|
return options
|
||||||
}
|
}
|
||||||
|
@ -119,8 +108,7 @@ export function searchInputMapping(
|
||||||
userColumnMapping(
|
userColumnMapping(
|
||||||
key,
|
key,
|
||||||
options,
|
options,
|
||||||
helpers.schema.isDeprecatedSingleUserColumn(column),
|
helpers.schema.isDeprecatedSingleUserColumn(column)
|
||||||
datasourceOptions.isSql
|
|
||||||
)
|
)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue