From c130f2976c06be02328ec12ca11b9fbd3b542972 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 9 May 2024 22:24:06 +0200 Subject: [PATCH 01/12] Change test --- packages/server/src/api/routes/tests/search.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 7a0e78eb1c..e12f495c5e 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -301,7 +301,7 @@ describe.each([ appointment: { name: "appointment", type: FieldType.DATETIME }, single_user: { name: "single_user", - type: FieldType.BB_REFERENCE, + type: FieldType.BB_REFERENCE_SINGLE, subtype: BBReferenceFieldSubType.USER, }, multi_user: { From f7a997aaef662724a08c57f098b175ffde8b6874 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 10 May 2024 10:48:17 +0200 Subject: [PATCH 02/12] Update some tests --- packages/server/src/api/routes/tests/search.spec.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index e12f495c5e..e79e667a3c 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -262,11 +262,11 @@ describe.each([ { name: "serverDate", appointment: serverTime.toISOString() }, { name: "single user, session user", - single_user: JSON.stringify([currentUser]), + single_user: JSON.stringify(currentUser), }, { name: "single user", - single_user: JSON.stringify([globalUsers[0]]), + single_user: JSON.stringify(globalUsers[0]), }, { name: "multi user", @@ -398,7 +398,7 @@ describe.each([ }).toContainExactly([ { name: "single user, session user", - single_user: [{ _id: config.getUser()._id }], + single_user: { _id: config.getUser()._id }, }, ]) }) @@ -447,11 +447,11 @@ describe.each([ }).toContainExactly([ { name: "single user, session user", - single_user: [{ _id: config.getUser()._id }], + single_user: { _id: config.getUser()._id }, }, { name: "single user", - single_user: [{ _id: globalUsers[0]._id }], + single_user: { _id: globalUsers[0]._id }, }, ]) }) @@ -467,7 +467,7 @@ describe.each([ }).toContainExactly([ { name: "single user", - single_user: [{ _id: globalUsers[0]._id }], + single_user: { _id: globalUsers[0]._id }, }, ]) }) From 1fc2efd6f58dada5644f8853c5ae5fd58ff4bd6e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 10 May 2024 11:20:19 +0200 Subject: [PATCH 03/12] Clean --- packages/server/src/api/routes/tests/search.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index e79e667a3c..455bd36a27 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -307,7 +307,7 @@ describe.each([ multi_user: { name: "multi_user", type: FieldType.BB_REFERENCE, - subtype: BBReferenceFieldSubType.USERS, + subtype: BBReferenceFieldSubType.USER, }, }) await createRows(rows(config.getUser())) From 2833e0558e38e3cb958e84edcf85d92e2a76138a Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 10 May 2024 11:26:43 +0200 Subject: [PATCH 04/12] Test deprecated_multi_user bindings --- .../src/api/routes/tests/search.spec.ts | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 455bd36a27..a1bf27df43 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -276,6 +276,14 @@ describe.each([ name: "multi user with session user", multi_user: JSON.stringify([...globalUsers, currentUser]), }, + { + name: "deprecated multi user", + deprecated_multi_user: JSON.stringify(globalUsers), + }, + { + name: "deprecated multi user with session user", + deprecated_multi_user: JSON.stringify([...globalUsers, currentUser]), + }, ] } @@ -304,11 +312,24 @@ describe.each([ type: FieldType.BB_REFERENCE_SINGLE, subtype: BBReferenceFieldSubType.USER, }, + deprecated_single_user: { + name: "deprecated_single_user", + type: FieldType.BB_REFERENCE_SINGLE, + subtype: BBReferenceFieldSubType.USER, + constraints: { + type: "array", + }, + }, multi_user: { name: "multi_user", type: FieldType.BB_REFERENCE, subtype: BBReferenceFieldSubType.USER, }, + deprecated_multi_user: { + name: "deprecated_multi_user", + type: FieldType.BB_REFERENCE, + subtype: BBReferenceFieldSubType.USERS, + }, }) await createRows(rows(config.getUser())) }) @@ -420,6 +441,23 @@ describe.each([ ]) }) + // TODO(samwho): fix for SQS + !isSqs && + it("should match the session user id in a deprecated multi user field", async () => { + const allUsers = [...globalUsers, config.getUser()].map((user: any) => { + return { _id: user._id } + }) + + await expectQuery({ + contains: { deprecated_multi_user: ["{{ [user]._id }}"] }, + }).toContainExactly([ + { + name: "deprecated multi user with session user", + deprecated_multi_user: allUsers, + }, + ]) + }) + // TODO(samwho): fix for SQS !isSqs && it("should not match the session user id in a multi user field", async () => { @@ -436,6 +474,22 @@ describe.each([ ]) }) + // TODO(samwho): fix for SQS + !isSqs && + it("should not match the session user id in a deprecated multi user field", async () => { + await expectQuery({ + notContains: { deprecated_multi_user: ["{{ [user]._id }}"] }, + notEmpty: { deprecated_multi_user: true }, + }).toContainExactly([ + { + name: "deprecated multi user", + deprecated_multi_user: globalUsers.map((user: any) => { + return { _id: user._id } + }), + }, + ]) + }) + it("should match the session user id and a user table row id using helpers, user binding and a static user id.", async () => { await expectQuery({ oneOf: { From fa2843b29643643e2fb44250bf08406efe313b00 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 10 May 2024 11:45:15 +0200 Subject: [PATCH 05/12] Improve tests --- .../src/api/routes/tests/search.spec.ts | 67 +++++++++++++++++-- packages/server/src/utilities/schema.ts | 6 +- 2 files changed, 65 insertions(+), 8 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index a1bf27df43..65456327c0 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -26,11 +26,11 @@ tk.freeze(serverTime) describe.each([ ["lucene", undefined], - ["sqs", undefined], - [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)], - [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)], - [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)], - [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)], + // ["sqs", undefined], + // [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)], + // [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)], + // [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)], + // [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)], ])("/api/:sourceId/search (%s)", (name, dsProvider) => { const isSqs = name === "sqs" const isLucene = name === "lucene" @@ -268,6 +268,14 @@ describe.each([ name: "single user", single_user: JSON.stringify(globalUsers[0]), }, + { + name: "deprecated single user, session user", + deprecated_single_user: JSON.stringify([currentUser]), + }, + { + name: "deprecated single user", + deprecated_single_user: JSON.stringify([globalUsers[0]]), + }, { name: "multi user", multi_user: JSON.stringify(globalUsers), @@ -314,7 +322,7 @@ describe.each([ }, deprecated_single_user: { name: "deprecated_single_user", - type: FieldType.BB_REFERENCE_SINGLE, + type: FieldType.BB_REFERENCE, subtype: BBReferenceFieldSubType.USER, constraints: { type: "array", @@ -424,6 +432,17 @@ describe.each([ ]) }) + it("should match a deprecated single user row by the session user id", async () => { + await expectQuery({ + equal: { deprecated_single_user: "{{ [user]._id }}" }, + }).toContainExactly([ + { + name: "deprecated single user, session user", + deprecated_single_user: [{ _id: config.getUser()._id }], + }, + ]) + }) + // TODO(samwho): fix for SQS !isSqs && it("should match the session user id in a multi user field", async () => { @@ -510,6 +529,26 @@ describe.each([ ]) }) + it("should match the session user id and a user table row id using helpers, user binding and a static user id. (deprecated single user)", async () => { + await expectQuery({ + oneOf: { + deprecated_single_user: [ + "{{ default [user]._id '_empty_' }}", + globalUsers[0]._id, + ], + }, + }).toContainExactly([ + { + name: "deprecated single user, session user", + deprecated_single_user: [{ _id: config.getUser()._id }], + }, + { + name: "deprecated single user", + deprecated_single_user: [{ _id: globalUsers[0]._id }], + }, + ]) + }) + it("should resolve 'default' helper to '_empty_' when binding resolves to nothing", async () => { await expectQuery({ oneOf: { @@ -525,6 +564,22 @@ describe.each([ }, ]) }) + + it("should resolve 'default' helper to '_empty_' when binding resolves to nothing (deprecated single user)", async () => { + await expectQuery({ + oneOf: { + deprecated_single_user: [ + "{{ default [user]._idx '_empty_' }}", + globalUsers[0]._id, + ], + }, + }).toContainExactly([ + { + name: "deprecated single user", + deprecated_single_user: [{ _id: globalUsers[0]._id }], + }, + ]) + }) }) describe.each([FieldType.STRING, FieldType.LONGFORM])("%s", () => { diff --git a/packages/server/src/utilities/schema.ts b/packages/server/src/utilities/schema.ts index 2dff1acb5c..4f0feb3c93 100644 --- a/packages/server/src/utilities/schema.ts +++ b/packages/server/src/utilities/schema.ts @@ -139,8 +139,10 @@ export function parse(rows: Rows, schema: TableSchema): Rows { ? new Date(columnData).toISOString() : columnData } else if (columnType === FieldType.BB_REFERENCE) { - const parsedValues = - (!!columnData && parseCsvExport<{ _id: string }[]>(columnData)) || [] + let parsedValues: { _id: string }[] = columnData || [] + if (columnData) { + parsedValues = parseCsvExport<{ _id: string }[]>(columnData) + } parsedRow[columnName] = parsedValues?.map(u => u._id) } else if (columnType === FieldType.BB_REFERENCE_SINGLE) { From 1732feed27ff9663d7ca727e49b8a0559b5cfbd4 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 10 May 2024 11:48:09 +0200 Subject: [PATCH 06/12] =?UTF-8?q?Uncomment=20=F0=9F=92=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/server/src/api/routes/tests/search.spec.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index 65456327c0..b21fd1fa04 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -26,11 +26,11 @@ tk.freeze(serverTime) describe.each([ ["lucene", undefined], - // ["sqs", undefined], - // [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)], - // [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)], - // [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)], - // [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)], + ["sqs", undefined], + [DatabaseName.POSTGRES, getDatasource(DatabaseName.POSTGRES)], + [DatabaseName.MYSQL, getDatasource(DatabaseName.MYSQL)], + [DatabaseName.SQL_SERVER, getDatasource(DatabaseName.SQL_SERVER)], + [DatabaseName.MARIADB, getDatasource(DatabaseName.MARIADB)], ])("/api/:sourceId/search (%s)", (name, dsProvider) => { const isSqs = name === "sqs" const isLucene = name === "lucene" From 68e2313e6cb2b0197896b6d8c5020ff7f92a9780 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 13 May 2024 10:28:35 +0200 Subject: [PATCH 07/12] Fix test setup --- packages/server/src/integrations/base/sqlTable.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/server/src/integrations/base/sqlTable.ts b/packages/server/src/integrations/base/sqlTable.ts index 2af3fb096e..a82a9fcea8 100644 --- a/packages/server/src/integrations/base/sqlTable.ts +++ b/packages/server/src/integrations/base/sqlTable.ts @@ -11,7 +11,7 @@ import { TableSourceType, } from "@budibase/types" import { breakExternalTableId, getNativeSql, SqlClient } from "../utils" -import { utils } from "@budibase/shared-core" +import { helpers, utils } from "@budibase/shared-core" import SchemaBuilder = Knex.SchemaBuilder import CreateTableBuilder = Knex.CreateTableBuilder @@ -85,7 +85,12 @@ function generateSchema( break case FieldType.ARRAY: case FieldType.BB_REFERENCE: - schema.json(key) + if (helpers.schema.isDeprecatedSingleUserColumn(column)) { + // This is still required for unit testing, in order to create "deprecated" schemas + schema.text(key) + } else { + schema.json(key) + } break case FieldType.LINK: // this side of the relationship doesn't need any SQL work From 5c8a7890474293764b43cdeedb14f0e9c109ad92 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 13 May 2024 10:50:59 +0200 Subject: [PATCH 08/12] Fix query --- packages/server/src/integrations/base/sql.ts | 4 +-- packages/server/src/sdk/app/rows/search.ts | 6 ++-- .../server/src/sdk/app/rows/search/utils.ts | 29 ++++++++++++++++--- 3 files changed, 31 insertions(+), 8 deletions(-) diff --git a/packages/server/src/integrations/base/sql.ts b/packages/server/src/integrations/base/sql.ts index 7a2b819007..85db642e47 100644 --- a/packages/server/src/integrations/base/sql.ts +++ b/packages/server/src/integrations/base/sql.ts @@ -26,6 +26,7 @@ import { INTERNAL_TABLE_SOURCE_ID, } from "@budibase/types" import environment from "../../environment" +import { helpers } from "@budibase/shared-core" type QueryFunction = (query: SqlQuery | SqlQuery[], operation: Operation) => any @@ -786,8 +787,7 @@ class SqlQueryBuilder extends SqlTableQueryBuilder { return ( field.type === FieldType.JSON || (field.type === FieldType.BB_REFERENCE && - // Handling old single user type - field.constraints?.type === "array") + !helpers.schema.isDeprecatedSingleUserColumn(field)) ) } diff --git a/packages/server/src/sdk/app/rows/search.ts b/packages/server/src/sdk/app/rows/search.ts index e347a8657d..7c61f48e31 100644 --- a/packages/server/src/sdk/app/rows/search.ts +++ b/packages/server/src/sdk/app/rows/search.ts @@ -12,7 +12,7 @@ import { NoEmptyFilterStrings } from "../../../constants" import * as sqs from "./search/sqs" import env from "../../../environment" import { ExportRowsParams, ExportRowsResult } from "./search/types" -import { dataFilters } from "@budibase/shared-core" +import { dataFilters, helpers } from "@budibase/shared-core" import sdk from "../../index" import { searchInputMapping } from "./search/utils" @@ -79,7 +79,9 @@ export async function search( } const table = await sdk.tables.getTable(options.tableId) - options = searchInputMapping(table, options) + options = searchInputMapping(table, options, { + isSql: !!table.sql || !!env.SQS_SEARCH_ENABLE, + }) if (isExternalTable) { return external.search(options, table) diff --git a/packages/server/src/sdk/app/rows/search/utils.ts b/packages/server/src/sdk/app/rows/search/utils.ts index 75f5d4e0ae..ca9ab1959c 100644 --- a/packages/server/src/sdk/app/rows/search/utils.ts +++ b/packages/server/src/sdk/app/rows/search/utils.ts @@ -11,7 +11,7 @@ import { RowSearchParams, } from "@budibase/types" import { db as dbCore, context } from "@budibase/backend-core" -import { utils } from "@budibase/shared-core" +import { helpers, utils } from "@budibase/shared-core" export async function paginatedSearch( query: SearchFilters, @@ -49,13 +49,19 @@ function findColumnInQueries( } } -function userColumnMapping(column: string, options: RowSearchParams) { +function userColumnMapping( + column: string, + options: RowSearchParams, + isDeprecatedSingleUserColumn: boolean = false, + isSql: boolean = false +) { findColumnInQueries(column, options, (filterValue: any): any => { const isArray = Array.isArray(filterValue), isString = typeof filterValue === "string" if (!isString && !isArray) { return filterValue } + const processString = (input: string) => { const rowPrefix = DocumentType.ROW + SEPARATOR if (input.startsWith(rowPrefix)) { @@ -64,6 +70,12 @@ function userColumnMapping(column: string, options: RowSearchParams) { return input } } + + if (isDeprecatedSingleUserColumn && filterValue && isString && isSql) { + // Decreated single users are stored as stringified arrays of a single value + return JSON.stringify([processString(filterValue)]) + } + if (isArray) { return filterValue.map(el => { if (typeof el === "string") { @@ -80,7 +92,11 @@ function userColumnMapping(column: string, options: RowSearchParams) { // maps through the search parameters to check if any of the inputs are invalid // based on the table schema, converts them to something that is valid. -export function searchInputMapping(table: Table, options: RowSearchParams) { +export function searchInputMapping( + table: Table, + options: RowSearchParams, + datasourceOptions: { isSql?: boolean } +) { if (!table?.schema) { return options } @@ -99,7 +115,12 @@ export function searchInputMapping(table: Table, options: RowSearchParams) { break } case FieldType.BB_REFERENCE: { - userColumnMapping(key, options) + userColumnMapping( + key, + options, + helpers.schema.isDeprecatedSingleUserColumn(column), + datasourceOptions.isSql + ) break } } From fdea7221e4ece9830cd3eac66248a43c44786480 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 13 May 2024 11:44:55 +0200 Subject: [PATCH 09/12] Fix filter operations --- packages/server/src/sdk/app/rows/search/utils.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/server/src/sdk/app/rows/search/utils.ts b/packages/server/src/sdk/app/rows/search/utils.ts index ca9ab1959c..42d84fff62 100644 --- a/packages/server/src/sdk/app/rows/search/utils.ts +++ b/packages/server/src/sdk/app/rows/search/utils.ts @@ -71,21 +71,22 @@ function userColumnMapping( } } - if (isDeprecatedSingleUserColumn && filterValue && isString && isSql) { + let wrapper = (s: string) => s + if (isDeprecatedSingleUserColumn && filterValue && isSql) { // Decreated single users are stored as stringified arrays of a single value - return JSON.stringify([processString(filterValue)]) + wrapper = (s: string) => JSON.stringify([s]) } if (isArray) { return filterValue.map(el => { if (typeof el === "string") { - return processString(el) + return wrapper(processString(el)) } else { return el } }) } else { - return processString(filterValue) + return wrapper(processString(filterValue)) } }) } From 91332ce4111a4c511a23ece1c1d412b819ccfa9e Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 13 May 2024 12:03:31 +0200 Subject: [PATCH 10/12] Lint --- packages/server/src/sdk/app/rows/search.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/sdk/app/rows/search.ts b/packages/server/src/sdk/app/rows/search.ts index 7c61f48e31..2d194ab196 100644 --- a/packages/server/src/sdk/app/rows/search.ts +++ b/packages/server/src/sdk/app/rows/search.ts @@ -12,7 +12,7 @@ import { NoEmptyFilterStrings } from "../../../constants" import * as sqs from "./search/sqs" import env from "../../../environment" import { ExportRowsParams, ExportRowsResult } from "./search/types" -import { dataFilters, helpers } from "@budibase/shared-core" +import { dataFilters } from "@budibase/shared-core" import sdk from "../../index" import { searchInputMapping } from "./search/utils" From e451e99f6b94f32de27381dfbc22a36e6d118e19 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 13 May 2024 12:13:57 +0200 Subject: [PATCH 11/12] Fixes --- packages/server/src/api/routes/tests/search.spec.ts | 9 ++++++--- packages/shared-core/src/filters.ts | 9 +++++++-- packages/shared-core/src/helpers/schema.ts | 4 +++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/packages/server/src/api/routes/tests/search.spec.ts b/packages/server/src/api/routes/tests/search.spec.ts index b21fd1fa04..87d0aa72c7 100644 --- a/packages/server/src/api/routes/tests/search.spec.ts +++ b/packages/server/src/api/routes/tests/search.spec.ts @@ -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())) diff --git a/packages/shared-core/src/filters.ts b/packages/shared-core/src/filters.ts index 2438e7f840..1401b75e93 100644 --- a/packages/shared-core/src/filters.ts +++ b/packages/shared-core/src/filters.ts @@ -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] diff --git a/packages/shared-core/src/helpers/schema.ts b/packages/shared-core/src/helpers/schema.ts index 548a5c9766..985e068be0 100644 --- a/packages/shared-core/src/helpers/schema.ts +++ b/packages/shared-core/src/helpers/schema.ts @@ -4,7 +4,9 @@ import { FieldType, } from "@budibase/types" -export function isDeprecatedSingleUserColumn(schema: FieldSchema) { +export function isDeprecatedSingleUserColumn( + schema: Pick +) { const result = schema.type === FieldType.BB_REFERENCE && schema.subtype === BBReferenceFieldSubType.USER && From 01b9d6069c10cf4e5483f63357bc889fc8a9e53b Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Mon, 13 May 2024 12:25:19 +0200 Subject: [PATCH 12/12] Fix build --- packages/server/src/sdk/app/rows/search/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/sdk/app/rows/search/utils.ts b/packages/server/src/sdk/app/rows/search/utils.ts index 42d84fff62..62f5af2b70 100644 --- a/packages/server/src/sdk/app/rows/search/utils.ts +++ b/packages/server/src/sdk/app/rows/search/utils.ts @@ -96,7 +96,7 @@ function userColumnMapping( export function searchInputMapping( table: Table, options: RowSearchParams, - datasourceOptions: { isSql?: boolean } + datasourceOptions: { isSql?: boolean } = {} ) { if (!table?.schema) { return options