From 6d6e83f7c87af6aa83a14e6646ecb29f84531e7a Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 27 Apr 2022 17:11:57 +0100 Subject: [PATCH] Fixing some issues with types being lost when fetching SQL tables, after making changes to tables within Budibase. --- packages/server/src/integrations/utils.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/server/src/integrations/utils.ts b/packages/server/src/integrations/utils.ts index d166523f1d..326b213bc7 100644 --- a/packages/server/src/integrations/utils.ts +++ b/packages/server/src/integrations/utils.ts @@ -207,11 +207,20 @@ function shouldCopySpecialColumn( column: { type: string }, fetchedColumn: { type: string } | undefined ) { + const specialTypes = [ + FieldTypes.OPTIONS, + FieldTypes.LONGFORM, + FieldTypes.ARRAY, + FieldTypes.FORMULA, + ] + if (column && !fetchedColumn) { + return true + } + const fetchedIsNumber = + !fetchedColumn || fetchedColumn.type === FieldTypes.NUMBER return ( - column.type === FieldTypes.OPTIONS || - column.type === FieldTypes.ARRAY || - ((!fetchedColumn || fetchedColumn.type === FieldTypes.NUMBER) && - column.type === FieldTypes.BOOLEAN) + specialTypes.indexOf(column.type) !== -1 || + (fetchedIsNumber && column.type === FieldTypes.BOOLEAN) ) }