diff options
author | Jacob Evans <jacob.evans@10gen.com> | 2019-04-12 12:21:15 -0400 |
---|---|---|
committer | Jacob Evans <jacob.evans@10gen.com> | 2019-05-03 14:36:58 -0400 |
commit | d226d5d236f2542bcece138c3c2337d67348d84d (patch) | |
tree | 125a55de39cbff86909a64f0d9e6f2d7e9ba1dca /src/mongo/db/pipeline/document_source_group_test.cpp | |
parent | 734266e9ec2f8cbf0b75bd7797f8b573262af471 (diff) | |
download | mongo-d226d5d236f2542bcece138c3c2337d67348d84d.tar.gz |
SERVER-40526 Make agg Expressions walkable
Diffstat (limited to 'src/mongo/db/pipeline/document_source_group_test.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_group_test.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/document_source_group_test.cpp b/src/mongo/db/pipeline/document_source_group_test.cpp index 111a2db01f2..da25b97d397 100644 --- a/src/mongo/db/pipeline/document_source_group_test.cpp +++ b/src/mongo/db/pipeline/document_source_group_test.cpp @@ -207,7 +207,20 @@ TEST_F(DocumentSourceGroupTest, ShouldReportMultipleFieldGroupKeysAsARename) { VariablesParseState vps = expCtx->variablesParseState; auto x = ExpressionFieldPath::parse(expCtx, "$x", vps); auto y = ExpressionFieldPath::parse(expCtx, "$y", vps); - auto groupByExpression = ExpressionObject::create(expCtx, {{"x", x}, {"y", y}}); + auto groupByExpression = [&]() { + std::vector<boost::intrusive_ptr<Expression>> children; + std::vector<std::pair<std::string, boost::intrusive_ptr<Expression>&>> expressions; + auto doc = std::vector<std::pair<std::string, boost::intrusive_ptr<Expression>>>{{"x", x}, + {"y", y}}; + for (auto & [ unused, expression ] : doc) + children.push_back(std::move(expression)); + std::vector<boost::intrusive_ptr<Expression>>::size_type index = 0; + for (auto & [ fieldName, unused ] : doc) { + expressions.emplace_back(fieldName, children[index]); + ++index; + } + return ExpressionObject::create(expCtx, std::move(children), std::move(expressions)); + }(); auto group = DocumentSourceGroup::create(expCtx, groupByExpression, {}); auto modifiedPathsRet = group->getModifiedPaths(); ASSERT(modifiedPathsRet.type == DocumentSource::GetModPathsReturn::Type::kAllExcept); |