From 29de393a2ff2ed1f5905ea0ad4d81a7a42ff1bbc Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Thu, 24 Nov 2022 11:45:58 +0000 Subject: [PATCH] Allow tables to be created even if no fetch --- .../TableIntegrationMenu/CreateExternalTableModal.svelte | 4 ++-- packages/server/src/api/controllers/table/external.js | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/CreateExternalTableModal.svelte b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/CreateExternalTableModal.svelte index f6cd6af758..45269a365c 100644 --- a/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/CreateExternalTableModal.svelte +++ b/packages/builder/src/components/backend/DatasourceNavigator/TableIntegrationMenu/CreateExternalTableModal.svelte @@ -7,9 +7,9 @@ let name = "" let submitted = false - $: valid = name && name.length > 0 && !datasource?.entities[name] + $: valid = name && name.length > 0 && !datasource?.entities?.[name] $: error = - !submitted && name && datasource?.entities[name] + !submitted && name && datasource?.entities?.[name] ? "Table name already in use." : null diff --git a/packages/server/src/api/controllers/table/external.js b/packages/server/src/api/controllers/table/external.js index fe9270fe1d..22fe10bfc3 100644 --- a/packages/server/src/api/controllers/table/external.js +++ b/packages/server/src/api/controllers/table/external.js @@ -190,6 +190,9 @@ exports.save = async function (ctx) { const db = getAppDB() const datasource = await db.get(datasourceId) + if (!datasource.entities) { + datasource.entities = {} + } const oldTables = cloneDeep(datasource.entities) const tables = datasource.entities