From 9f27cb95b9aebcf22e5e6a243d35f04b846edf9e Mon Sep 17 00:00:00 2001 From: victor-meng <56978073+victor-meng@users.noreply.github.com> Date: Fri, 15 Oct 2021 12:33:59 -0700 Subject: [PATCH] Only use the SET keyword once in the update query (#1138) --- src/Explorer/Tables/TableDataClient.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Explorer/Tables/TableDataClient.ts b/src/Explorer/Tables/TableDataClient.ts index 4eaa1172b..afe31b711 100644 --- a/src/Explorer/Tables/TableDataClient.ts +++ b/src/Explorer/Tables/TableDataClient.ts @@ -202,14 +202,21 @@ export class CassandraAPIDataClient extends TableDataClient { let updateQuery = `UPDATE ${collection.databaseId}.${collection.id()}`; let isPropertyUpdated = false; + let isFirstPropertyToUpdate = true; for (let property in newEntity) { if ( !originalDocument[property] || newEntity[property]._.toString() !== originalDocument[property]._.toString() ) { - updateQuery += this.isStringType(newEntity[property].$) - ? ` SET ${property} = '${newEntity[property]._}',` - : ` SET ${property} = ${newEntity[property]._},`; + let propertyQuerySegment = this.isStringType(newEntity[property].$) + ? `${property} = '${newEntity[property]._}',` + : `${property} = ${newEntity[property]._},`; + // Only add the "SET" keyword once + if (isFirstPropertyToUpdate) { + propertyQuerySegment = " SET " + propertyQuerySegment; + isFirstPropertyToUpdate = false; + } + updateQuery += propertyQuerySegment; isPropertyUpdated = true; } }