summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops/modifier_compare.cpp
diff options
context:
space:
mode:
authorApollon Oikonomopoulos <apoikos@debian.org>2018-03-22 12:08:05 +0200
committerApollon Oikonomopoulos <apoikos@debian.org>2018-03-22 12:08:05 +0200
commit72ad42c506a506ef238d4b1fdcf2b9da5668bfb9 (patch)
treedf94bdab3d6f16e14016f4547b9e86f368ba8150 /src/mongo/db/ops/modifier_compare.cpp
parent648fcfa3cf11ba8fdb7bb64c52f3159b4351ae3c (diff)
parentc49e99631589113663b1a3ac691870421965a315 (diff)
Update upstream source from tag 'upstream/3.4.14'
Update to upstream version '3.4.14' with Debian dir 8c079cd0bdbb1831aa5b89a3b7d4c1b4a1b891a2
Diffstat (limited to 'src/mongo/db/ops/modifier_compare.cpp')
-rw-r--r--src/mongo/db/ops/modifier_compare.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/db/ops/modifier_compare.cpp b/src/mongo/db/ops/modifier_compare.cpp
index 4e366f90ee2..7db7abd09ca 100644
--- a/src/mongo/db/ops/modifier_compare.cpp
+++ b/src/mongo/db/ops/modifier_compare.cpp
@@ -110,6 +110,8 @@ Status ModifierCompare::prepare(mutablebson::Element root,
// be created during the apply.
Status status = pathsupport::findLongestPrefix(
_updatePath, root, &_preparedState->idxFound, &_preparedState->elemFound);
+ const auto elemFoundIsArray =
+ _preparedState->elemFound.ok() && _preparedState->elemFound.getType() == BSONType::Array;
// FindLongestPrefix may say the path does not exist at all, which is fine here, or
// that the path was not viable or otherwise wrong, in which case, the mod cannot
@@ -128,6 +130,11 @@ Status ModifierCompare::prepare(mutablebson::Element root,
_preparedState->idxFound == (_updatePath.numParts() - 1));
if (!destExists) {
execInfo->noOp = false;
+
+ if (elemFoundIsArray) {
+ // Report that an existing array will gain a new element as a result of this mod.
+ execInfo->indexOfArrayWithNewElement[0] = _preparedState->idxFound;
+ }
} else {
const int compareVal =
_preparedState->elemFound.compareWithBSONElement(_val, _collator, false);