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

View File

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