From d482b012630992b1b2d780705e054392c1d2f088 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Wed, 6 Oct 2021 17:52:12 +0100 Subject: [PATCH] Fixing issue #2276 - allows reverting a SQL column to null if no input. --- packages/server/src/api/controllers/row/ExternalRequest.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/server/src/api/controllers/row/ExternalRequest.ts b/packages/server/src/api/controllers/row/ExternalRequest.ts index 3e9c707e69..222f921018 100644 --- a/packages/server/src/api/controllers/row/ExternalRequest.ts +++ b/packages/server/src/api/controllers/row/ExternalRequest.ts @@ -178,7 +178,12 @@ module External { manyRelationships: ManyRelationship[] = [] for (let [key, field] of Object.entries(table.schema)) { // if set already, or not set just skip it - if (!row[key] || newRow[key] || field.autocolumn) { + if ((!row[key] && row[key] !== "") || newRow[key] || field.autocolumn) { + continue + } + // if its an empty string then it means return the column to null (if possible) + if (row[key] === "") { + newRow[key] = null continue } // parse floats/numbers