1
0
Fork 0
mirror of synced 2024-08-23 05:51:29 +12:00
This commit is contained in:
Adria Navarro 2024-05-13 12:13:57 +02:00
parent 91332ce411
commit e451e99f6b
3 changed files with 16 additions and 6 deletions

View file

@ -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()))

View file

@ -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
@ -24,6 +25,7 @@ export const getValidOperatorsForType = (
type: FieldType
subtype?: BBReferenceFieldSubType
formulaType?: FormulaType
constraints?: FieldConstraints
},
field?: string,
datasource?: Datasource & { tableId: any }
@ -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]

View file

@ -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 &&