From 2be14deb010dd096149028bdc2e84dde43cf6637 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Fri, 26 Apr 2024 13:26:14 +0200 Subject: [PATCH] Add test --- .../src/api/routes/tests/datasource.spec.ts | 22 ++++++------------- .../src/documents/app/table/constants.ts | 17 ++++++++++++++ 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/packages/server/src/api/routes/tests/datasource.spec.ts b/packages/server/src/api/routes/tests/datasource.spec.ts index 761300c37a..f2cea90675 100644 --- a/packages/server/src/api/routes/tests/datasource.spec.ts +++ b/packages/server/src/api/routes/tests/datasource.spec.ts @@ -16,6 +16,7 @@ import { SourceName, Table, TableSchema, + SupportedSqlTypes, } from "@budibase/types" import { DatabaseName, getDatasource } from "../../../integrations/tests/utils" import { tableForDatasource } from "../../../tests/utilities/structures" @@ -261,20 +262,6 @@ describe("/datasources", () => { }) ) - type SupportedSqlTypes = - | FieldType.STRING - | FieldType.BARCODEQR - | FieldType.LONGFORM - | FieldType.OPTIONS - | FieldType.DATETIME - | FieldType.NUMBER - | FieldType.BOOLEAN - | FieldType.FORMULA - | FieldType.BIGINT - | FieldType.BB_REFERENCE - | FieldType.LINK - | FieldType.ARRAY - const fullSchema: { [type in SupportedSqlTypes]: FieldSchema & { type: type } } = { @@ -337,7 +324,12 @@ describe("/datasources", () => { [FieldType.BB_REFERENCE]: { name: "bb_reference", type: FieldType.BB_REFERENCE, - subtype: BBReferenceFieldSubType.USERS, + subtype: BBReferenceFieldSubType.USER, + }, + [FieldType.BB_REFERENCE_SINGLE]: { + name: "bb_reference_single", + type: FieldType.BB_REFERENCE_SINGLE, + subtype: BBReferenceFieldSubType.USER, }, } diff --git a/packages/types/src/documents/app/table/constants.ts b/packages/types/src/documents/app/table/constants.ts index d836496657..210ad1423d 100644 --- a/packages/types/src/documents/app/table/constants.ts +++ b/packages/types/src/documents/app/table/constants.ts @@ -1,3 +1,5 @@ +import { FieldType } from "../row" + export enum RelationshipType { ONE_TO_MANY = "one-to-many", MANY_TO_ONE = "many-to-one", @@ -30,3 +32,18 @@ export enum BBReferenceFieldSubType { /** @deprecated this should not be used anymore, left here in order to support the existing usages */ USERS = "users", } + +export type SupportedSqlTypes = + | FieldType.STRING + | FieldType.BARCODEQR + | FieldType.LONGFORM + | FieldType.OPTIONS + | FieldType.DATETIME + | FieldType.NUMBER + | FieldType.BOOLEAN + | FieldType.FORMULA + | FieldType.BIGINT + | FieldType.BB_REFERENCE + | FieldType.BB_REFERENCE_SINGLE + | FieldType.LINK + | FieldType.ARRAY