mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-06-04 22:52:31 +01:00
Only use the SET keyword once in the update query (#1138)
This commit is contained in:
parent
271256bffb
commit
9f27cb95b9
@ -202,14 +202,21 @@ export class CassandraAPIDataClient extends TableDataClient {
|
|||||||
|
|
||||||
let updateQuery = `UPDATE ${collection.databaseId}.${collection.id()}`;
|
let updateQuery = `UPDATE ${collection.databaseId}.${collection.id()}`;
|
||||||
let isPropertyUpdated = false;
|
let isPropertyUpdated = false;
|
||||||
|
let isFirstPropertyToUpdate = true;
|
||||||
for (let property in newEntity) {
|
for (let property in newEntity) {
|
||||||
if (
|
if (
|
||||||
!originalDocument[property] ||
|
!originalDocument[property] ||
|
||||||
newEntity[property]._.toString() !== originalDocument[property]._.toString()
|
newEntity[property]._.toString() !== originalDocument[property]._.toString()
|
||||||
) {
|
) {
|
||||||
updateQuery += this.isStringType(newEntity[property].$)
|
let propertyQuerySegment = this.isStringType(newEntity[property].$)
|
||||||
? ` SET ${property} = '${newEntity[property]._}',`
|
? `${property} = '${newEntity[property]._}',`
|
||||||
: ` SET ${property} = ${newEntity[property]._},`;
|
: `${property} = ${newEntity[property]._},`;
|
||||||
|
// Only add the "SET" keyword once
|
||||||
|
if (isFirstPropertyToUpdate) {
|
||||||
|
propertyQuerySegment = " SET " + propertyQuerySegment;
|
||||||
|
isFirstPropertyToUpdate = false;
|
||||||
|
}
|
||||||
|
updateQuery += propertyQuerySegment;
|
||||||
isPropertyUpdated = true;
|
isPropertyUpdated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user