diff options
Diffstat (limited to 'src/mongo/db/pipeline/document_source_lookup.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_lookup.cpp | 9 |
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 ef11b582394..3f5d2eb8efa 100644 --- a/src/mongo/db/pipeline/document_source_lookup.cpp +++ b/src/mongo/db/pipeline/document_source_lookup.cpp @@ -60,7 +60,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, |