Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adrinr committed May 13, 2024
1 parent d9bd33c commit b6a7447
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
9 changes: 6 additions & 3 deletions packages/server/src/api/routes/tests/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,19 +324,22 @@ describe.each([
name: "deprecated_single_user",
type: FieldType.BB_REFERENCE,
subtype: BBReferenceFieldSubType.USER,
constraints: {
type: "array",
},
},
multi_user: {
name: "multi_user",
type: FieldType.BB_REFERENCE,
subtype: BBReferenceFieldSubType.USER,
constraints: {
type: "array",
},
},
deprecated_multi_user: {
name: "deprecated_multi_user",
type: FieldType.BB_REFERENCE,
subtype: BBReferenceFieldSubType.USERS,
constraints: {
type: "array",
},
},
})
await createRows(rows(config.getUser()))
Expand Down
9 changes: 7 additions & 2 deletions packages/shared-core/src/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import {
SearchFilterOperator,
SortDirection,
SortType,
FieldConstraints,
} from "@budibase/types"
import dayjs from "dayjs"
import { OperatorOptions, SqlNumberTypeRangeMap } from "./constants"
import { deepGet } from "./helpers"
import { deepGet, schema } from "./helpers"

const HBS_REGEX = /{{([^{].*?)}}/g

Expand All @@ -24,6 +25,7 @@ export const getValidOperatorsForType = (
type: FieldType
subtype?: BBReferenceFieldSubType
formulaType?: FormulaType
constraints?: FieldConstraints
},
field?: string,
datasource?: Datasource & { tableId: any }
Expand Down Expand Up @@ -68,7 +70,10 @@ export const getValidOperatorsForType = (
ops = numOps
} else if (type === FieldType.FORMULA && formulaType === FormulaType.STATIC) {
ops = stringOps.concat([Op.MoreThan, Op.LessThan])
} else if (type === FieldType.BB_REFERENCE_SINGLE) {
} else if (
type === FieldType.BB_REFERENCE_SINGLE ||
schema.isDeprecatedSingleUserColumn(fieldType)
) {
ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In]
} else if (type === FieldType.BB_REFERENCE) {
ops = [Op.Contains, Op.NotContains, Op.ContainsAny, Op.Empty, Op.NotEmpty]
Expand Down
4 changes: 3 additions & 1 deletion packages/shared-core/src/helpers/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import {
FieldType,
} from "@budibase/types"

export function isDeprecatedSingleUserColumn(schema: FieldSchema) {
export function isDeprecatedSingleUserColumn(
schema: Pick<FieldSchema, "type" | "subtype" | "constraints">
) {
const result =
schema.type === FieldType.BB_REFERENCE &&
schema.subtype === BBReferenceFieldSubType.USER &&
Expand Down

0 comments on commit b6a7447

Please sign in to comment.