summaryrefslogtreecommitdiff
path: root/src/mongo/db/pipeline/document_source_lookup.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/pipeline/document_source_lookup.cpp')
-rw-r--r--src/mongo/db/pipeline/document_source_lookup.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/mongo/db/pipeline/document_source_lookup.cpp b/src/mongo/db/pipeline/document_source_lookup.cpp
index a4b1bf4221a..575d3335ba4 100644
--- a/src/mongo/db/pipeline/document_source_lookup.cpp
+++ b/src/mongo/db/pipeline/document_source_lookup.cpp
@@ -61,7 +61,14 @@ DocumentSourceLookUp::DocumentSourceLookUp(NamespaceString fromNs,
const auto& resolvedNamespace = expCtx->getResolvedNamespace(_fromNs);
_resolvedNs = resolvedNamespace.ns;
_resolvedPipeline = resolvedNamespace.pipeline;
- _fromExpCtx = expCtx->copyWith(_resolvedNs);
+
+ // We always set an explicit collator on the copied expression context, even if the collator is
+ // null (i.e. the simple collation). Otherwise, in the situation where the user did not specify
+ // a collation and the simple collation was inherited from the local collection, the execution
+ // machinery will incorrectly interpret the null collator and empty user collation as an
+ // indication that it should inherit the foreign collection's collation.
+ _fromExpCtx = expCtx->copyWith(
+ _resolvedNs, boost::none, expCtx->getCollator() ? expCtx->getCollator()->clone() : nullptr);
_fromExpCtx->subPipelineDepth += 1;
uassert(ErrorCodes::MaxSubPipelineDepthExceeded,