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