summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/aggregation_request.cpp
diff options
context:
space:
mode:
authorJames Wahlin <james@mongodb.com>2017-07-03 15:33:36 -0400
committerJames Wahlin <james@mongodb.com>2017-07-25 12:24:49 -0400
commit5dcaad5f137eebc1915c0fc7b5078da4aa86f915 (patch)
tree3994b41708bce7cf5cbc5b7c9ba422db77f9bfb3 /src/mongo/db/pipeline/aggregation_request.cpp
parent079763d2cd06776edf81f3ecf6c32ab66d1742ec (diff)
downloadmongo-5dcaad5f137eebc1915c0fc7b5078da4aa86f915.tar.gz
SERVER-29371 DocumentSource classes should provide auth requirements
Diffstat (limited to 'src/mongo/db/pipeline/aggregation_request.cpp')
-rw-r--r--src/mongo/db/pipeline/aggregation_request.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/mongo/db/pipeline/aggregation_request.cpp b/src/mongo/db/pipeline/aggregation_request.cpp
index 844907bd89a..8947c6f9a03 100644
--- a/src/mongo/db/pipeline/aggregation_request.cpp
+++ b/src/mongo/db/pipeline/aggregation_request.cpp
@@ -216,10 +216,14 @@ StatusWith<AggregationRequest> AggregationRequest::parseFromBSON(
request.setExplain(explainVerbosity);
}
- if (!hasCursorElem && !request.getExplain()) {
+ // 'hasExplainElem' implies an aggregate command-level explain option, which does not require
+ // a cursor argument.
+ if (!hasCursorElem && !hasExplainElem) {
return {ErrorCodes::FailedToParse,
- str::stream() << "The '" << kCursorName
- << "' option is required, except for aggregation explain"};
+ str::stream()
+ << "The '"
+ << kCursorName
+ << "' option is required, except for aggregate with the explain argument"};
}
if (request.getExplain() && !request.getReadConcern().isEmpty()) {
@@ -277,8 +281,9 @@ Document AggregationRequest::serializeToCommandObj() const {
_bypassDocumentValidation ? Value(true) : Value()},
// Only serialize a collation if one was specified.
{kCollationName, _collation.isEmpty() ? Value() : Value(_collation)},
- // Only serialize batchSize when explain is false.
- {kCursorName, _explainMode ? Value() : Value(Document{{kBatchSizeName, _batchSize}})},
+ // Only serialize batchSize if not an explain, otherwise serialize an empty cursor object.
+ {kCursorName,
+ _explainMode ? Value(Document()) : Value(Document{{kBatchSizeName, _batchSize}})},
// Only serialize a hint if one was specified.
{kHintName, _hint.isEmpty() ? Value() : Value(_hint)},
// Only serialize a comment if one was specified.