From 31499dd163068b6c70a1d2a072aaa9576a628ff0 Mon Sep 17 00:00:00 2001 From: Arun Banala Date: Thu, 11 Jun 2020 10:47:55 +0100 Subject: SERVER-48684 Pipeline stage $set fails to set a non-existent dotted field to an object --- src/mongo/db/exec/inclusion_projection_executor.h | 24 +++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/mongo/db/exec/inclusion_projection_executor.h') diff --git a/src/mongo/db/exec/inclusion_projection_executor.h b/src/mongo/db/exec/inclusion_projection_executor.h index b095a423652..b26b62859ed 100644 --- a/src/mongo/db/exec/inclusion_projection_executor.h +++ b/src/mongo/db/exec/inclusion_projection_executor.h @@ -43,8 +43,10 @@ namespace mongo::projection_executor { */ class InclusionNode : public ProjectionNode { public: - InclusionNode(ProjectionPolicies policies, std::string pathToNode = "") - : ProjectionNode(policies, std::move(pathToNode)) {} + InclusionNode(ProjectionPolicies policies, + bool containsComputedFields, + std::string pathToNode = "") + : ProjectionNode(policies, containsComputedFields, std::move(pathToNode)) {} InclusionNode* addOrGetChild(const std::string& field) { return static_cast(ProjectionNode::addOrGetChild(field)); @@ -83,7 +85,9 @@ protected: } std::unique_ptr makeChild(const std::string& fieldName) const override { return std::make_unique( - _policies, FieldPath::getFullyQualifiedPath(_pathToNode, fieldName)); + _policies, + _subtreeContainsComputedFields, + FieldPath::getFullyQualifiedPath(_pathToNode, fieldName)); } MutableDocument initializeOutputDocument(const Document& inputDoc) const final { // Technically this value could be min(number of projected fields, size of input @@ -112,15 +116,19 @@ protected: */ class FastPathEligibleInclusionNode final : public InclusionNode { public: - FastPathEligibleInclusionNode(ProjectionPolicies policies, std::string pathToNode = "") - : InclusionNode(policies, std::move(pathToNode)) {} + FastPathEligibleInclusionNode(ProjectionPolicies policies, + bool containsComputedFields, + std::string pathToNode = "") + : InclusionNode(policies, containsComputedFields, std::move(pathToNode)) {} Document applyToDocument(const Document& inputDoc) const final; protected: std::unique_ptr makeChild(const std::string& fieldName) const final { return std::make_unique( - _policies, FieldPath::getFullyQualifiedPath(_pathToNode, fieldName)); + _policies, + _subtreeContainsComputedFields, + FieldPath::getFullyQualifiedPath(_pathToNode, fieldName)); } private: @@ -147,8 +155,8 @@ public: : InclusionProjectionExecutor( expCtx, policies, - allowFastPath ? std::make_unique(policies) - : std::make_unique(policies)) {} + allowFastPath ? std::make_unique(policies, false) + : std::make_unique(policies, false)) {} TransformerType getType() const final { return TransformerType::kInclusionProjection; -- cgit v1.2.1