From 2cc329994a16ff3010259837782bdcf49aace95c Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 22 May 2024 17:18:39 +0200 Subject: [PATCH 1/3] Don't allow chaning time only to datetime --- .../DataTable/modals/CreateEditColumn.svelte | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index e88c28a9d9..26d0357b5f 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -604,27 +604,29 @@ - {#if datasource?.source !== SourceName.ORACLE && datasource?.source !== SourceName.SQL_SERVER && !editableColumn.dateOnly} -
-
- - - - + {#if !editableColumn.timeOnly} + {#if datasource?.source !== SourceName.ORACLE && datasource?.source !== SourceName.SQL_SERVER && !editableColumn.dateOnly} +
+
+ + + + +
+
- -
+ {/if} + {/if} - {:else if editableColumn.type === FieldType.NUMBER && !editableColumn.autocolumn}
From b3bea1e839b091efbe4beac0e50faa981c5e1716 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Wed, 22 May 2024 17:18:58 +0200 Subject: [PATCH 2/3] Block timeOnly changes in the api --- packages/server/src/sdk/app/tables/external/index.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/server/src/sdk/app/tables/external/index.ts b/packages/server/src/sdk/app/tables/external/index.ts index 98e6e561c8..53302085fc 100644 --- a/packages/server/src/sdk/app/tables/external/index.ts +++ b/packages/server/src/sdk/app/tables/external/index.ts @@ -73,6 +73,16 @@ function validate(table: Table, oldTable?: Table) { `Column "${key}" has subtype "${column.subtype}" - this is not supported.` ) } + + if (column.type === FieldType.DATETIME) { + const oldColumn = oldTable?.schema[key] as typeof column + + if (column.timeOnly !== oldColumn.timeOnly) { + throw new Error( + `Column "${key}" can not change from time to datetime or viceversa.` + ) + } + } } } From 028afd9cca04808615b672f9979f62af469b13d5 Mon Sep 17 00:00:00 2001 From: Adria Navarro Date: Thu, 23 May 2024 11:34:58 +0200 Subject: [PATCH 3/3] Fix checks --- packages/server/src/sdk/app/tables/external/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/server/src/sdk/app/tables/external/index.ts b/packages/server/src/sdk/app/tables/external/index.ts index 53302085fc..842b6b5648 100644 --- a/packages/server/src/sdk/app/tables/external/index.ts +++ b/packages/server/src/sdk/app/tables/external/index.ts @@ -77,7 +77,7 @@ function validate(table: Table, oldTable?: Table) { if (column.type === FieldType.DATETIME) { const oldColumn = oldTable?.schema[key] as typeof column - if (column.timeOnly !== oldColumn.timeOnly) { + if (oldColumn && column.timeOnly !== oldColumn.timeOnly) { throw new Error( `Column "${key}" can not change from time to datetime or viceversa.` )