summaryrefslogtreecommitdiff
path: root/src/mongo/db/ops/parsed_update.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/ops/parsed_update.cpp')
-rw-r--r--src/mongo/db/ops/parsed_update.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/src/mongo/db/ops/parsed_update.cpp b/src/mongo/db/ops/parsed_update.cpp
index c21933d9876..fbdc4e0a43e 100644
--- a/src/mongo/db/ops/parsed_update.cpp
+++ b/src/mongo/db/ops/parsed_update.cpp
@@ -122,15 +122,14 @@ Status ParsedUpdate::parseQueryToCQ() {
// The projection needs to be applied after the update operation, so we do not specify a
// projection during canonicalization.
- auto qr = std::make_unique<QueryRequest>(_request->getNamespaceString());
- qr->setFilter(_request->getQuery());
- qr->setSort(_request->getSort());
- qr->setExplain(static_cast<bool>(_request->explain()));
- qr->setHint(_request->getHint());
+ auto findCommand = std::make_unique<FindCommand>(_request->getNamespaceString());
+ findCommand->setFilter(_request->getQuery());
+ findCommand->setSort(_request->getSort());
+ findCommand->setHint(_request->getHint());
// We get the collation off the ExpressionContext because it may contain a collection-default
// collator if no collation was included in the user's request.
- qr->setCollation(_expCtx->getCollatorBSON());
+ findCommand->setCollation(_expCtx->getCollatorBSON());
// Limit should only used for the findAndModify command when a sort is specified. If a sort
// is requested, we want to use a top-k sort for efficiency reasons, so should pass the
@@ -139,7 +138,7 @@ Status ParsedUpdate::parseQueryToCQ() {
// has not actually updated a document. This behavior is fine for findAndModify, but should
// not apply to update in general.
if (!_request->isMulti() && !_request->getSort().isEmpty()) {
- qr->setLimit(1);
+ findCommand->setLimit(1);
}
// $expr is not allowed in the query for an upsert, since it is not clear what the equality
@@ -151,16 +150,20 @@ Status ParsedUpdate::parseQueryToCQ() {
}
// If the update request has runtime constants or let parameters attached to it, pass them to
- // the QueryRequest.
+ // the FindCommand.
if (auto& runtimeConstants = _request->getLegacyRuntimeConstants()) {
- qr->setLegacyRuntimeConstants(*runtimeConstants);
+ findCommand->setLegacyRuntimeConstants(*runtimeConstants);
}
if (auto& letParams = _request->getLetParameters()) {
- qr->setLetParameters(*letParams);
+ findCommand->setLet(*letParams);
}
- auto statusWithCQ = CanonicalQuery::canonicalize(
- _opCtx, std::move(qr), _expCtx, _extensionsCallback, allowedMatcherFeatures);
+ auto statusWithCQ = CanonicalQuery::canonicalize(_opCtx,
+ std::move(findCommand),
+ static_cast<bool>(_request->explain()),
+ _expCtx,
+ _extensionsCallback,
+ allowedMatcherFeatures);
if (statusWithCQ.isOK()) {
_canonicalQuery = std::move(statusWithCQ.getValue());
}