1
0
Fork 0

don't update if there's nothing to do

This commit is contained in:
Jan Steemann 2016-07-06 07:38:44 +02:00
parent f9bafa4b14
commit 7455ef20ef
1 changed files with 15 additions and 14 deletions

View File

@ -720,7 +720,7 @@ AqlItemBlock* UpsertBlock::work(std::vector<AqlItemBlock*>& blocks) {
updateBuilder.clear(); updateBuilder.clear();
size_t const n = res->size(); size_t const n = res->size();
bool const isMultiple = (n > 1); bool const isMultiple = (n > 1);
if (isMultiple) { if (isMultiple) {
insertBuilder.openArray(); insertBuilder.openArray();
@ -750,20 +750,21 @@ AqlItemBlock* UpsertBlock::work(std::vector<AqlItemBlock*>& blocks) {
AqlValue const& updateDoc = res->getValueReference(i, updateRegisterId); AqlValue const& updateDoc = res->getValueReference(i, updateRegisterId);
if (updateDoc.isObject()) { if (updateDoc.isObject()) {
VPackSlice toUpdate = updateDoc.slice(); if (updateDoc.length() > 0) {
VPackSlice toUpdate = updateDoc.slice();
keyBuilder.clear();
keyBuilder.openObject(); keyBuilder.clear();
keyBuilder.add(StaticStrings::KeyString, VPackValue(key)); keyBuilder.openObject();
keyBuilder.close(); keyBuilder.add(StaticStrings::KeyString, VPackValue(key));
if (isMultiple) { keyBuilder.close();
VPackBuilder tmp = VPackCollection::merge(toUpdate, keyBuilder.slice(), false, false); if (isMultiple) {
updateBuilder.add(tmp.slice()); VPackBuilder tmp = VPackCollection::merge(toUpdate, keyBuilder.slice(), false, false);
upRows.emplace_back(dstRow); updateBuilder.add(tmp.slice());
} else { upRows.emplace_back(dstRow);
updateBuilder = VPackCollection::merge(toUpdate, keyBuilder.slice(), false, false); } else {
updateBuilder = VPackCollection::merge(toUpdate, keyBuilder.slice(), false, false);
}
} }
} else { } else {
errorCode = TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID; errorCode = TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID;
} }