From f105232d6594336e35cfee8f7f6d4ef49182ce84 Mon Sep 17 00:00:00 2001 From: Ian Boros Date: Fri, 20 Mar 2020 16:22:40 -0400 Subject: SERVER-46863 prevent collator mismatch in findAndModify/update --- src/mongo/db/ops/parsed_update.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/mongo/db/ops') diff --git a/src/mongo/db/ops/parsed_update.cpp b/src/mongo/db/ops/parsed_update.cpp index b495d48df9c..cdcc2428029 100644 --- a/src/mongo/db/ops/parsed_update.cpp +++ b/src/mongo/db/ops/parsed_update.cpp @@ -121,10 +121,13 @@ Status ParsedUpdate::parseQueryToCQ() { auto qr = std::make_unique(_request->getNamespaceString()); qr->setFilter(_request->getQuery()); qr->setSort(_request->getSort()); - qr->setCollation(_request->getCollation()); qr->setExplain(_request->isExplain()); qr->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()); + // 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 // limit through. Generally, a update stage expects to be able to skip documents that were -- cgit v1.2.1