diff options
| author | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-18 17:02:53 -0300 |
|---|---|---|
| committer | Lucas de Castro Borges <lucas@gnuabordo.com.br> | 2025-02-18 17:02:53 -0300 |
| commit | 959575a5ca598bf5f37fb5cebe7ed1d80d3d71f7 (patch) | |
| tree | acc8d60aedb12b70048e676e8a7349deb0010db8 /src/mongo/db/pipeline/document_source_documents.cpp | |
| parent | 76588293975fc059cf076779e4283e6ffaf8afff (diff) | |
New upstream version 6.0.20upstream
Diffstat (limited to 'src/mongo/db/pipeline/document_source_documents.cpp')
| -rw-r--r-- | src/mongo/db/pipeline/document_source_documents.cpp | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mongo/db/pipeline/document_source_documents.cpp b/src/mongo/db/pipeline/document_source_documents.cpp index 934116a7c27..23f5b8c96f8 100644 --- a/src/mongo/db/pipeline/document_source_documents.cpp +++ b/src/mongo/db/pipeline/document_source_documents.cpp @@ -50,26 +50,26 @@ REGISTER_DOCUMENT_SOURCE(documents, std::list<intrusive_ptr<DocumentSource>> DocumentSourceDocuments::createFromBson( BSONElement elem, const intrusive_ptr<ExpressionContext>& expCtx) { - // genField is a temporary field to hold docs to wire $project, - // $unwind, and $replaceRoot together. - auto genField = UUID::gen().toString(); - auto projectContent = BSON(genField << elem); + // kGenFieldName is a temporary field to hold docs to wire $project, $unwind, and $replaceRoot + // together. This may show up in explain, but it will not possibly overlap with user data, since + // the user data is nested a level below, within an array or object. + auto projectContent = BSON(kGenFieldName << elem); auto queue = DocumentSourceQueue::create(expCtx, DocumentSourceDocuments::kStageName); queue->emplace_back(Document{}); /* Create the following pipeline from $documents: [...] - * => [ queue([{}]), - * project: {tempDocumentsField: [...]}, - * unwind: "$tempDocumentsField", - * replaceWith: "$tempDocumentsField" ] + * => [ {$queue: [{}] }, + * {$project: {[kGenFieldName]: [...]}}, + * {$unwind: "$" + kGenFieldName}, + * {$replaceWith: "$" + kGenFieldName} ] */ - return { - queue, - DocumentSourceProject::create(projectContent, expCtx, elem.fieldNameStringData()), - DocumentSourceUnwind::create(expCtx, genField, false, {}, true), - DocumentSourceReplaceRoot::create(expCtx, - ExpressionFieldPath::createPathFromString( - expCtx.get(), genField, expCtx->variablesParseState), - "elements within the array passed to $documents")}; + return {queue, + DocumentSourceProject::create(projectContent, expCtx, elem.fieldNameStringData()), + DocumentSourceUnwind::create(expCtx, kGenFieldName, false, {}, true), + DocumentSourceReplaceRoot::create( + expCtx, + ExpressionFieldPath::createPathFromString( + expCtx.get(), kGenFieldName, expCtx->variablesParseState), + "elements within the array passed to $documents")}; } } // namespace mongo |
