diff options
author | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2018-09-21 14:35:16 -0400 |
---|---|---|
committer | Nick Zolnierz <nicholas.zolnierz@mongodb.com> | 2018-10-04 09:53:18 -0400 |
commit | 41820e4b371e389e8cbe965dc9aff14f657a9040 (patch) | |
tree | 511ef7e3e15a067f0f0a2dd93495b0f3b18e6050 /src/mongo/db/update | |
parent | 1e026f75dc41cca4c7293e42b5b49cb9e46d0ea3 (diff) | |
download | mongo-41820e4b371e389e8cbe965dc9aff14f657a9040.tar.gz |
SERVER-37058: Update with numeric field names inside an array can cause validation to fail
Diffstat (limited to 'src/mongo/db/update')
-rw-r--r-- | src/mongo/db/update/modifier_node.cpp | 16 | ||||
-rw-r--r-- | src/mongo/db/update/update_node_test_fixture.h | 2 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/mongo/db/update/modifier_node.cpp b/src/mongo/db/update/modifier_node.cpp index a85b636ac0d..37135de3b99 100644 --- a/src/mongo/db/update/modifier_node.cpp +++ b/src/mongo/db/update/modifier_node.cpp @@ -189,8 +189,7 @@ UpdateNode::ApplyResult ModifierNode::applyToExistingElement(ApplyParams applyPa ApplyResult applyResult; - if (!applyParams.indexData || - !applyParams.indexData->mightBeIndexed(applyParams.pathTaken->dottedField())) { + if (!applyParams.indexData || !applyParams.indexData->mightBeIndexed(*applyParams.pathTaken)) { applyResult.indexesAffected = false; } @@ -270,12 +269,12 @@ UpdateNode::ApplyResult ModifierNode::applyToNonexistentElement(ApplyParams appl } invariant(!applyParams.pathToCreate->empty()); - std::string fullPath; + FieldRef fullPath; if (applyParams.pathTaken->empty()) { - fullPath = applyParams.pathToCreate->dottedField().toString(); + fullPath = *applyParams.pathToCreate; } else { - fullPath = str::stream() << applyParams.pathTaken->dottedField() << "." - << applyParams.pathToCreate->dottedField(); + fullPath = FieldRef(str::stream() << applyParams.pathTaken->dottedField() << "." + << applyParams.pathToCreate->dottedField()); } ApplyResult applyResult; @@ -289,12 +288,13 @@ UpdateNode::ApplyResult ModifierNode::applyToNonexistentElement(ApplyParams appl if (!applyParams.indexData || !applyParams.indexData->mightBeIndexed(applyParams.element.getType() != BSONType::Array ? fullPath - : applyParams.pathTaken->dottedField())) { + : *applyParams.pathTaken)) { applyResult.indexesAffected = false; } if (applyParams.logBuilder) { - logUpdate(applyParams.logBuilder, fullPath, newElement, ModifyResult::kCreated); + logUpdate( + applyParams.logBuilder, fullPath.dottedField(), newElement, ModifyResult::kCreated); } return applyResult; diff --git a/src/mongo/db/update/update_node_test_fixture.h b/src/mongo/db/update/update_node_test_fixture.h index 6da205a2cb8..725f9ba0c46 100644 --- a/src/mongo/db/update/update_node_test_fixture.h +++ b/src/mongo/db/update/update_node_test_fixture.h @@ -113,7 +113,7 @@ protected: if (!_indexData) { _indexData = stdx::make_unique<UpdateIndexData>(); } - _indexData->addPath(path); + _indexData->addPath(FieldRef(path)); } void setLogBuilderToNull() { |