Fetch only table fields and validate

This commit is contained in:
Adria Navarro 2024-08-09 10:16:07 +02:00
parent 79ca65e39a
commit 120d5d953d
1 changed files with 13 additions and 0 deletions

View File

@ -73,6 +73,19 @@ export async function search(
const table = await sdk.tables.getTable(options.tableId)
options = searchInputMapping(table, options)
const visibleTableFields = Object.keys(table.schema).filter(
f => table.schema[f].visible !== false
)
if (options.fields) {
const tableFields = visibleTableFields.map(f => f.toLowerCase())
options.fields = options.fields.filter(f =>
tableFields.includes(f.toLowerCase())
)
} else {
options.fields = visibleTableFields
}
let result: SearchResponse<Row>
if (isExternalTable) {
span?.addTags({ searchType: "external" })