summaryrefslogtreecommitdiff
path: root/src/mongo/db/exec/projection_executor_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/exec/projection_executor_test.cpp')
-rw-r--r--src/mongo/db/exec/projection_executor_test.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/mongo/db/exec/projection_executor_test.cpp b/src/mongo/db/exec/projection_executor_test.cpp
index 7d3b7410205..a1ac7467510 100644
--- a/src/mongo/db/exec/projection_executor_test.cpp
+++ b/src/mongo/db/exec/projection_executor_test.cpp
@@ -176,4 +176,11 @@ TEST_F(ProjectionExecutorTest, CanProjectFindSliceAndPositional) {
Document{fromjson("{a: {b: [2,3]}, c: [6]}")},
executor->applyTransformation(Document{fromjson("{a: {b: [1,2,3,4]}, c: [5,6,7]}")}));
}
+
+TEST_F(ProjectionExecutorTest, ExecutorOptimizesExpression) {
+ auto proj = parseWithDefaultPolicies(fromjson("{a: 1, b: {$add: [1, 2]}}"));
+ auto executor = buildProjectionExecutor(getExpCtx(), &proj, {});
+ ASSERT_DOCUMENT_EQ(Document{fromjson("{_id: true, a: true, b: {$const: 3}}")},
+ executor->serializeTransformation(boost::none));
+}
} // namespace mongo::projection_executor