From 5e9f3969c90c0beacba432f395a6985028ac13c9 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Fri, 26 Nov 2021 14:14:53 +0000 Subject: [PATCH] Fixing a few issues that became obvious when I was looking at examples of what gets sent to the API for table saving. --- .../backend/DataTable/modals/CreateEditColumn.svelte | 3 +++ packages/builder/src/stores/backend/tables.js | 2 +- packages/server/src/api/controllers/table/internal.js | 4 ---- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index c47bf1a538..b88a66d222 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -102,6 +102,9 @@ if (field.type === AUTO_TYPE) { field = buildAutoColumn($tables.draft.name, field.name, field.subtype) } + if (field.type !== LINK_TYPE) { + delete field.fieldName + } try { await tables.saveField({ originalName, diff --git a/packages/builder/src/stores/backend/tables.js b/packages/builder/src/stores/backend/tables.js index c63685914b..02db48c549 100644 --- a/packages/builder/src/stores/backend/tables.js +++ b/packages/builder/src/stores/backend/tables.js @@ -122,7 +122,7 @@ export function createTablesStore() { update(state => { // delete the original if renaming // need to handle if the column had no name, empty string - if (originalName || originalName === "") { + if (originalName != null && originalName !== field.name) { delete state.draft.schema[originalName] state.draft._rename = { old: originalName, diff --git a/packages/server/src/api/controllers/table/internal.js b/packages/server/src/api/controllers/table/internal.js index 660618aef0..10a5c9746a 100644 --- a/packages/server/src/api/controllers/table/internal.js +++ b/packages/server/src/api/controllers/table/internal.js @@ -44,14 +44,10 @@ exports.save = async function (ctx) { // the column if you want to change the type if (oldTable && oldTable.schema) { for (let propKey of Object.keys(tableToSave.schema)) { - let column = tableToSave.schema[propKey] let oldColumn = oldTable.schema[propKey] if (oldColumn && oldColumn.type === "internal") { oldColumn.type = "auto" } - if (oldColumn && oldColumn.type !== column.type) { - ctx.throw(400, "Cannot change the type of a column") - } } }