0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-12-01 09:32:32 +01:00

SERVER-24882 Reject expressions in aggregation's exclusion projection.

This commit is contained in:
Max Hirschhorn 2016-07-01 17:26:20 -04:00
parent aca39983fa
commit 8757e22c07
2 changed files with 13 additions and 0 deletions

View File

@ -184,6 +184,7 @@ private:
"add computed fields during an exclusion projection: "
<< _rawObj.toString(),
!_parsedType || _parsedType == ProjectionType::kInclusion);
_parsedType = ProjectionType::kInclusion;
ensurePathDoesNotConflictOrThrow(prefix.fullPath());
continue;
}

View File

@ -186,13 +186,25 @@ TEST(ParsedAggregationProjectionType, ShouldRejectMixOfExclusionAndComputedField
ParsedAggregationProjection::create(BSON("a" << false << "b" << wrapInLiteral(1))),
UserException);
ASSERT_THROWS(
ParsedAggregationProjection::create(BSON("a" << wrapInLiteral(1) << "b" << false)),
UserException);
ASSERT_THROWS(
ParsedAggregationProjection::create(BSON("a.b" << false << "a.c" << wrapInLiteral(1))),
UserException);
ASSERT_THROWS(
ParsedAggregationProjection::create(BSON("a.b" << wrapInLiteral(1) << "a.c" << false)),
UserException);
ASSERT_THROWS(ParsedAggregationProjection::create(
BSON("a" << BSON("b" << false << "c" << wrapInLiteral(1)))),
UserException);
ASSERT_THROWS(ParsedAggregationProjection::create(
BSON("a" << BSON("b" << wrapInLiteral(1) << "c" << false))),
UserException);
}
TEST(ParsedAggregationProjectionErrors, ShouldRejectDottedFieldInSubDocument) {