Cleanup SQS flag from view search
This commit is contained in:
parent
e50f2cc84e
commit
5b1ed8195a
|
@ -1,11 +1,7 @@
|
||||||
import {
|
import {
|
||||||
EmptyFilterOption,
|
EmptyFilterOption,
|
||||||
FeatureFlag,
|
|
||||||
LegacyFilter,
|
|
||||||
LogicalOperator,
|
|
||||||
Row,
|
Row,
|
||||||
RowSearchParams,
|
RowSearchParams,
|
||||||
SearchFilterKey,
|
|
||||||
SearchResponse,
|
SearchResponse,
|
||||||
SortOrder,
|
SortOrder,
|
||||||
Table,
|
Table,
|
||||||
|
@ -18,7 +14,6 @@ import { ExportRowsParams, ExportRowsResult } from "./search/types"
|
||||||
import { dataFilters } from "@budibase/shared-core"
|
import { dataFilters } from "@budibase/shared-core"
|
||||||
import sdk from "../../index"
|
import sdk from "../../index"
|
||||||
import { checkFilters, searchInputMapping } from "./search/utils"
|
import { checkFilters, searchInputMapping } from "./search/utils"
|
||||||
import { db, features } from "@budibase/backend-core"
|
|
||||||
import tracer from "dd-trace"
|
import tracer from "dd-trace"
|
||||||
import { getQueryableFields, removeInvalidFilters } from "./queryUtils"
|
import { getQueryableFields, removeInvalidFilters } from "./queryUtils"
|
||||||
import { enrichSearchContext } from "../../../api/controllers/row/utils"
|
import { enrichSearchContext } from "../../../api/controllers/row/utils"
|
||||||
|
@ -102,45 +97,14 @@ export async function search(
|
||||||
viewQuery = checkFilters(table, viewQuery)
|
viewQuery = checkFilters(table, viewQuery)
|
||||||
delete viewQuery?.onEmptyFilter
|
delete viewQuery?.onEmptyFilter
|
||||||
|
|
||||||
const sqsEnabled = await features.flags.isEnabled(FeatureFlag.SQS)
|
const conditions = viewQuery ? [viewQuery] : []
|
||||||
const supportsLogicalOperators =
|
options.query = {
|
||||||
isExternalTableID(view.tableId) || sqsEnabled
|
$and: {
|
||||||
|
conditions: [...conditions, options.query],
|
||||||
if (!supportsLogicalOperators) {
|
},
|
||||||
// In the unlikely event that a Grouped Filter is in a non-SQS environment
|
}
|
||||||
// It needs to be ignored entirely
|
if (viewQuery.onEmptyFilter) {
|
||||||
let queryFilters: LegacyFilter[] = Array.isArray(view.query)
|
options.query.onEmptyFilter = viewQuery.onEmptyFilter
|
||||||
? view.query
|
|
||||||
: []
|
|
||||||
|
|
||||||
delete options.query.onEmptyFilter
|
|
||||||
|
|
||||||
// Extract existing fields
|
|
||||||
const existingFields =
|
|
||||||
queryFilters
|
|
||||||
?.filter(filter => filter.field)
|
|
||||||
.map(filter => db.removeKeyNumbering(filter.field)) || []
|
|
||||||
|
|
||||||
// Carry over filters for unused fields
|
|
||||||
Object.keys(options.query).forEach(key => {
|
|
||||||
const operator = key as Exclude<SearchFilterKey, LogicalOperator>
|
|
||||||
Object.keys(options.query[operator] || {}).forEach(field => {
|
|
||||||
if (!existingFields.includes(db.removeKeyNumbering(field))) {
|
|
||||||
viewQuery[operator]![field] = options.query[operator]![field]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
options.query = viewQuery
|
|
||||||
} else {
|
|
||||||
const conditions = viewQuery ? [viewQuery] : []
|
|
||||||
options.query = {
|
|
||||||
$and: {
|
|
||||||
conditions: [...conditions, options.query],
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if (viewQuery.onEmptyFilter) {
|
|
||||||
options.query.onEmptyFilter = viewQuery.onEmptyFilter
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue