Respond to PR comment.

This commit is contained in:
Sam Rose 2024-10-11 16:22:04 +01:00
parent 1ad371cd7a
commit b24c337834
No known key found for this signature in database
1 changed files with 9 additions and 9 deletions

View File

@ -96,10 +96,10 @@ export async function search(
// 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 = await enrichSearchContext(view.query || {}, context)
query = dataFilters.buildQueryLegacy(query) || {}
query = checkFilters(table, query)
delete query?.onEmptyFilter
let viewQuery = await enrichSearchContext(view.query || {}, context)
viewQuery = dataFilters.buildQueryLegacy(viewQuery) || {}
viewQuery = checkFilters(table, viewQuery)
delete viewQuery?.onEmptyFilter
const sqsEnabled = await features.flags.isEnabled("SQS")
const supportsLogicalOperators =
@ -125,20 +125,20 @@ export async function search(
const operator = key as Exclude<SearchFilterKey, LogicalOperator>
Object.keys(options.query[operator] || {}).forEach(field => {
if (!existingFields.includes(db.removeKeyNumbering(field))) {
query[operator]![field] = options.query[operator]![field]
viewQuery[operator]![field] = options.query[operator]![field]
}
})
})
options.query = query
options.query = viewQuery
} else {
const conditions = query ? [query] : []
const conditions = viewQuery ? [viewQuery] : []
options.query = {
$and: {
conditions: [...conditions, options.query],
},
}
if (query.onEmptyFilter) {
options.query.onEmptyFilter = query.onEmptyFilter
if (viewQuery.onEmptyFilter) {
options.query.onEmptyFilter = viewQuery.onEmptyFilter
}
}
}