Fix - thanks tests.

This commit is contained in:
mike12345567 2024-09-09 16:40:04 +01:00
parent ac2416dc0b
commit 1a27cf9d5b
1 changed files with 6 additions and 3 deletions

View File

@ -22,7 +22,7 @@ import {
} from "@budibase/types"
import dayjs from "dayjs"
import { OperatorOptions, SqlNumberTypeRangeMap } from "./constants"
import { schema } from "./helpers"
import { deepGet, schema } from "./helpers"
import { isPlainObject, isEmpty } from "lodash"
import { decodeNonAscii } from "./helpers/schema"
@ -496,8 +496,11 @@ export const runQuery = (docs: Record<string, any>[], query: SearchFilters) => {
test: (docValue: any, testValue: any) => boolean
) =>
(doc: Record<string, any>) => {
for (const testValue of Object.values(query[type] || {})) {
const result = test(doc, testValue)
for (const [key, testValue] of Object.entries(query[type] || {})) {
const valueToCheck = isLogicalSearchOperator(type)
? doc
: deepGet(doc, removeKeyNumbering(key))
const result = test(valueToCheck, testValue)
if (query.allOr && result) {
return true
} else if (!query.allOr && !result) {