diff options
Diffstat (limited to 'src/mongo/db/pipeline/document_source_documents.cpp')
| -rw-r--r-- | src/mongo/db/pipeline/document_source_documents.cpp | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/mongo/db/pipeline/document_source_documents.cpp b/src/mongo/db/pipeline/document_source_documents.cpp index 23f5b8c96f8..5d4e02c71ea 100644 --- a/src/mongo/db/pipeline/document_source_documents.cpp +++ b/src/mongo/db/pipeline/document_source_documents.cpp @@ -44,32 +44,32 @@ namespace mongo { using boost::intrusive_ptr; REGISTER_DOCUMENT_SOURCE(documents, - DocumentSourceDocuments::LiteParsed::parse, + LiteParsedDocumentSourceDefault::parse, DocumentSourceDocuments::createFromBson, AllowedWithApiStrict::kAlways); std::list<intrusive_ptr<DocumentSource>> DocumentSourceDocuments::createFromBson( BSONElement elem, const intrusive_ptr<ExpressionContext>& expCtx) { - // 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); + // 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); auto queue = DocumentSourceQueue::create(expCtx, DocumentSourceDocuments::kStageName); queue->emplace_back(Document{}); /* Create the following pipeline from $documents: [...] - * => [ {$queue: [{}] }, - * {$project: {[kGenFieldName]: [...]}}, - * {$unwind: "$" + kGenFieldName}, - * {$replaceWith: "$" + kGenFieldName} ] + * => [ queue([{}]), + * project: {tempDocumentsField: [...]}, + * unwind: "$tempDocumentsField", + * replaceWith: "$tempDocumentsField" ] */ - 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")}; + 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")}; } } // namespace mongo |
