Fix uses of SearchFilterOperator.

This commit is contained in:
Sam Rose 2024-07-10 11:08:11 +01:00
parent 093579a341
commit 5356cfdce5
No known key found for this signature in database
2 changed files with 11 additions and 10 deletions

View File

@ -18,9 +18,10 @@ import {
CouchFindOptions,
DatabaseQueryOpts,
SearchFilters,
SearchFilterOperator,
SearchUsersRequest,
User,
BasicOperator,
ArrayOperator,
} from "@budibase/types"
import * as context from "../context"
import { getGlobalDB } from "../context"
@ -46,9 +47,9 @@ function removeUserPassword(users: User | User[]) {
export function isSupportedUserSearch(query: SearchFilters) {
const allowed = [
{ op: SearchFilterOperator.STRING, key: "email" },
{ op: SearchFilterOperator.EQUAL, key: "_id" },
{ op: SearchFilterOperator.ONE_OF, key: "_id" },
{ op: BasicOperator.STRING, key: "email" },
{ op: BasicOperator.EQUAL, key: "_id" },
{ op: ArrayOperator.ONE_OF, key: "_id" },
]
for (let [key, operation] of Object.entries(query)) {
if (typeof operation !== "object") {

View File

@ -9,7 +9,6 @@ import {
QuotaUsageType,
Row,
SaveTableRequest,
SearchFilterOperator,
SortOrder,
SortType,
StaticQuotaName,
@ -19,6 +18,7 @@ import {
ViewUIFieldMetadata,
ViewV2,
SearchResponse,
BasicOperator,
} from "@budibase/types"
import { generator, mocks } from "@budibase/backend-core/tests"
import { DatabaseName, getDatasource } from "../../../integrations/tests/utils"
@ -149,7 +149,7 @@ describe.each([
primaryDisplay: "id",
query: [
{
operator: SearchFilterOperator.EQUAL,
operator: BasicOperator.EQUAL,
field: "field",
value: "value",
},
@ -561,7 +561,7 @@ describe.each([
...view,
query: [
{
operator: SearchFilterOperator.EQUAL,
operator: BasicOperator.EQUAL,
field: "newField",
value: "thatValue",
},
@ -589,7 +589,7 @@ describe.each([
primaryDisplay: "Price",
query: [
{
operator: SearchFilterOperator.EQUAL,
operator: BasicOperator.EQUAL,
field: generator.word(),
value: generator.word(),
},
@ -673,7 +673,7 @@ describe.each([
tableId: generator.guid(),
query: [
{
operator: SearchFilterOperator.EQUAL,
operator: BasicOperator.EQUAL,
field: "newField",
value: "thatValue",
},
@ -1194,7 +1194,7 @@ describe.each([
name: generator.guid(),
query: [
{
operator: SearchFilterOperator.EQUAL,
operator: BasicOperator.EQUAL,
field: "two",
value: "bar2",
},