From 0b65459f9f650a624d903c15974e329f6f9ac375 Mon Sep 17 00:00:00 2001 From: Mutasem Aldmour <4711238+mutdmour@users.noreply.github.com> Date: Wed, 16 Jun 2021 13:41:35 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=20only=20update=20tags=20if=20s?= =?UTF-8?q?et=20in=20request=20(#1900)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * only update tags if set in request * only create relations/sort if tags exist --- packages/cli/src/Server.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/Server.ts b/packages/cli/src/Server.ts index b7ce5394b5..f19c88289e 100644 --- a/packages/cli/src/Server.ts +++ b/packages/cli/src/Server.ts @@ -673,10 +673,13 @@ class App { await WorkflowHelpers.validateWorkflow(updateData); await Db.collections.Workflow!.update(id, updateData).catch(WorkflowHelpers.throwDuplicateEntryError); - const tablePrefix = config.get('database.tablePrefix'); - await TagHelpers.removeRelations(req.params.id, tablePrefix); - if (tags?.length) { - await TagHelpers.createRelations(req.params.id, tags, tablePrefix); + if (tags) { + const tablePrefix = config.get('database.tablePrefix'); + await TagHelpers.removeRelations(req.params.id, tablePrefix); + + if (tags.length) { + await TagHelpers.createRelations(req.params.id, tags, tablePrefix); + } } // We sadly get nothing back from "update". Neither if it updated a record