summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorRuoxin Xu <ruoxin.xu@mongodb.com>2021-01-19 15:34:37 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-01-30 21:50:14 +0000
commit193823453567d03d2c41e35e9dd526311c0f6f3f (patch)
tree3dc4d99ea3534ddba3fa70f942c208fc2c7d483c /src/mongo/db/commands
parent75832e5ba1915f93f858998f6d4205d424fff455 (diff)
downloadmongo-193823453567d03d2c41e35e9dd526311c0f6f3f.tar.gz
SERVER-51624 Modify query commands to enforce API version 1 behaviour
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/count_cmd.cpp7
-rw-r--r--src/mongo/db/commands/distinct.cpp7
-rw-r--r--src/mongo/db/commands/find_cmd.cpp13
-rw-r--r--src/mongo/db/commands/mr_common.h1
-rw-r--r--src/mongo/db/commands/pipeline_command.cpp5
5 files changed, 25 insertions, 8 deletions
diff --git a/src/mongo/db/commands/count_cmd.cpp b/src/mongo/db/commands/count_cmd.cpp
index 3bb4c6031f1..1164eb1e07c 100644
--- a/src/mongo/db/commands/count_cmd.cpp
+++ b/src/mongo/db/commands/count_cmd.cpp
@@ -163,8 +163,11 @@ public:
auto viewAggCmd =
OpMsgRequest::fromDBAndBody(nss.db(), viewAggregation.getValue()).body;
- auto viewAggRequest =
- aggregation_request_helper::parseFromBSON(nss, viewAggCmd, verbosity);
+ auto viewAggRequest = aggregation_request_helper::parseFromBSON(
+ nss,
+ viewAggCmd,
+ verbosity,
+ APIParameters::get(opCtx).getAPIStrict().value_or(false));
if (!viewAggRequest.isOK()) {
return viewAggRequest.getStatus();
}
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 70a710ff044..53c8497beee 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -161,8 +161,11 @@ public:
auto viewAggCmd =
OpMsgRequest::fromDBAndBody(nss.db(), viewAggregation.getValue()).body;
- auto viewAggRequest =
- aggregation_request_helper::parseFromBSON(nss, viewAggCmd, verbosity);
+ auto viewAggRequest = aggregation_request_helper::parseFromBSON(
+ nss,
+ viewAggCmd,
+ verbosity,
+ APIParameters::get(opCtx).getAPIStrict().value_or(false));
if (!viewAggRequest.isOK()) {
return viewAggRequest.getStatus();
}
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index 7e51b1538d6..32c6cdcb0b8 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -70,7 +70,11 @@ std::unique_ptr<QueryRequest> parseCmdObjectToQueryRequest(OperationContext* opC
NamespaceString nss,
BSONObj cmdObj,
bool isExplain) {
- auto qr = QueryRequest::makeFromFindCommand(std::move(cmdObj), isExplain, std::move(nss));
+ auto qr =
+ QueryRequest::makeFromFindCommand(std::move(cmdObj),
+ isExplain,
+ std::move(nss),
+ APIParameters::get(opCtx).getAPIStrict().value_or(false));
if (!qr->getLegacyRuntimeConstants()) {
qr->setLegacyRuntimeConstants(Variables::generateRuntimeConstants(opCtx));
}
@@ -270,8 +274,11 @@ public:
auto viewAggCmd = OpMsgRequest::fromDBAndBody(_dbName, viewAggregationCommand).body;
// Create the agg request equivalent of the find operation, with the explain
// verbosity included.
- auto aggRequest = uassertStatusOK(
- aggregation_request_helper::parseFromBSON(nss, viewAggCmd, verbosity));
+ auto aggRequest = uassertStatusOK(aggregation_request_helper::parseFromBSON(
+ nss,
+ viewAggCmd,
+ verbosity,
+ APIParameters::get(opCtx).getAPIStrict().value_or(false)));
try {
// An empty PrivilegeVector is acceptable because these privileges are only
diff --git a/src/mongo/db/commands/mr_common.h b/src/mongo/db/commands/mr_common.h
index c3e80c11874..5e5c6dc55e7 100644
--- a/src/mongo/db/commands/mr_common.h
+++ b/src/mongo/db/commands/mr_common.h
@@ -36,6 +36,7 @@
#include "mongo/db/commands/map_reduce_gen.h"
#include "mongo/db/jsobj.h"
#include "mongo/db/namespace_string.h"
+#include "mongo/db/pipeline/pipeline.h"
namespace mongo::map_reduce_common {
diff --git a/src/mongo/db/commands/pipeline_command.cpp b/src/mongo/db/commands/pipeline_command.cpp
index 6535d11c2b1..341c42d1aca 100644
--- a/src/mongo/db/commands/pipeline_command.cpp
+++ b/src/mongo/db/commands/pipeline_command.cpp
@@ -73,7 +73,10 @@ public:
const OpMsgRequest& opMsgRequest,
boost::optional<ExplainOptions::Verbosity> explainVerbosity) override {
const auto aggregationRequest = uassertStatusOK(aggregation_request_helper::parseFromBSON(
- opMsgRequest.getDatabase().toString(), opMsgRequest.body, explainVerbosity));
+ opMsgRequest.getDatabase().toString(),
+ opMsgRequest.body,
+ explainVerbosity,
+ APIParameters::get(opCtx).getAPIStrict().value_or(false)));
auto privileges =
uassertStatusOK(AuthorizationSession::get(opCtx->getClient())