Skip to content

Commit

Permalink
Merge pull request #14669 from Budibase/better-types-on-removeInvalid…
Browse files Browse the repository at this point in the history
…Filters

Remove an implicit any from removeInvalidFilters.
  • Loading branch information
samwho authored Sep 30, 2024
2 parents 8462b4e + 26bcbba commit 6b3867f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
13 changes: 9 additions & 4 deletions packages/server/src/sdk/app/rows/queryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ export const removeInvalidFilters = (

validFields = validFields.map(f => f.toLowerCase())
for (const filterKey of Object.keys(result) as (keyof SearchFilters)[]) {
const filter = result[filterKey]
if (!filter || typeof filter !== "object") {
continue
}
if (isLogicalSearchOperator(filterKey)) {
const filter = result[filterKey]
if (!filter || typeof filter !== "object") {
continue
}
const resultingConditions: SearchFilters[] = []
for (const condition of filter.conditions) {
const resultingCondition = removeInvalidFilters(condition, validFields)
Expand All @@ -36,6 +36,11 @@ export const removeInvalidFilters = (
continue
}

const filter = result[filterKey]
if (!filter || typeof filter !== "object") {
continue
}

for (const columnKey of Object.keys(filter)) {
const possibleKeys = [columnKey, db.removeKeyNumbering(columnKey)].map(
c => c.toLowerCase()
Expand Down
10 changes: 4 additions & 6 deletions packages/types/src/sdk/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type RangeFilter = Record<
[InternalSearchFilterOperator.COMPLEX_ID_OPERATOR]?: never
}

type LogicalFilter = { conditions: SearchFilters[] }

export type AnySearchFilter = BasicFilter | ArrayFilter | RangeFilter

export interface SearchFilters {
Expand All @@ -92,12 +94,8 @@ export interface SearchFilters {
// specific document type (such as just rows)
documentType?: DocumentType

[LogicalOperator.AND]?: {
conditions: SearchFilters[]
}
[LogicalOperator.OR]?: {
conditions: SearchFilters[]
}
[LogicalOperator.AND]?: LogicalFilter
[LogicalOperator.OR]?: LogicalFilter
}

export type SearchFilterKey = keyof Omit<
Expand Down

0 comments on commit 6b3867f

Please sign in to comment.