mirror of
https://github.com/mongodb/mongo.git
synced 2024-11-21 12:39:08 +01:00
SERVER-96513 address todo from lookup.search ticket (#28763)
GitOrigin-RevId: ea618a4a0cf2abaf45a3f2106b855662fd2683a0
This commit is contained in:
parent
ea201514e2
commit
776fa92558
@ -97,58 +97,57 @@ let expectedResults = [
|
||||
];
|
||||
let results = addFieldsView.aggregate(pipeline).toArray();
|
||||
assertArrayEq({actual: results, expected: expectedResults});
|
||||
// TODO SERVER-93638 uncomment rest of test when $lookup.search on views support is enabled.
|
||||
// // Make sure if storedSource query is part of a inner subpipeline, the view transforms aren't
|
||||
// // applied by mongod.
|
||||
// const baseColl = testDb.baseColl;
|
||||
// baseColl.drop();
|
||||
// assert.commandWorked(
|
||||
// baseColl.insertMany([{state: "AK"}, {state: "CA"}, {state: "NY"}, {state: "NJ"}]));
|
||||
|
||||
// let storedSourceAsSubPipe = [
|
||||
// {
|
||||
// $lookup: {
|
||||
// from: viewName,
|
||||
// localField: "state",
|
||||
// foreignField: "state",
|
||||
// as: "state_facts",
|
||||
// pipeline
|
||||
// }
|
||||
// }, {$project: {_id: 0, "state_facts.state": 0}}
|
||||
// ];
|
||||
// explain = baseColl.explain().aggregate(storedSourceAsSubPipe);
|
||||
// assertViewNotApplied(explain.stages, viewPipeline);
|
||||
// Make sure if storedSource query is part of a inner subpipeline, the view transforms aren't
|
||||
// applied by mongod.
|
||||
const baseColl = testDb.baseColl;
|
||||
baseColl.drop();
|
||||
assert.commandWorked(
|
||||
baseColl.insertMany([{state: "AK"}, {state: "CA"}, {state: "NY"}, {state: "NJ"}]));
|
||||
|
||||
// expectedResults = [
|
||||
// {
|
||||
// state: "AK",
|
||||
// state_facts:
|
||||
// [{pop: 3000000, facts: {state_motto: "Regnat Populus", official_state_colors: []}}]
|
||||
// },
|
||||
// {
|
||||
// state: "CA",
|
||||
// state_facts: [
|
||||
// {pop: 39000000,
|
||||
// facts: {state_motto: "Eureka", official_state_colors: ["blue", "gold"]}}
|
||||
// ]
|
||||
// },
|
||||
// {
|
||||
// state: "NY",
|
||||
// state_facts: [{pop: 19000000, facts: {state_motto: "Excelsior", official_state_colors:
|
||||
// []}}]
|
||||
// },
|
||||
// {
|
||||
// state: "NJ",
|
||||
// state_facts: [{
|
||||
// pop: 9000000,
|
||||
// facts: {
|
||||
// state_motto: "Liberty and Prosperity",
|
||||
// official_state_colors: ["jersey blue", "bluff"]
|
||||
// }
|
||||
// }]
|
||||
// }
|
||||
// ];
|
||||
// results = baseColl.aggregate(storedSourceAsSubPipe).toArray();
|
||||
// assertArrayEq({actual: results, expected: expectedResults});
|
||||
let storedSourceAsSubPipe = [
|
||||
{
|
||||
$lookup: {
|
||||
from: viewName,
|
||||
localField: "state",
|
||||
foreignField: "state",
|
||||
as: "state_facts",
|
||||
pipeline
|
||||
}
|
||||
}, {$project: {_id: 0, "state_facts.state": 0}}
|
||||
];
|
||||
explain = baseColl.explain().aggregate(storedSourceAsSubPipe);
|
||||
assertViewNotApplied(explain.stages, viewPipeline);
|
||||
|
||||
expectedResults = [
|
||||
{
|
||||
state: "AK",
|
||||
state_facts:
|
||||
[{pop: 3000000, facts: {state_motto: "Regnat Populus", official_state_colors: []}}]
|
||||
},
|
||||
{
|
||||
state: "CA",
|
||||
state_facts: [
|
||||
{pop: 39000000,
|
||||
facts: {state_motto: "Eureka", official_state_colors: ["blue", "gold"]}}
|
||||
]
|
||||
},
|
||||
{
|
||||
state: "NY",
|
||||
state_facts: [{pop: 19000000, facts: {state_motto: "Excelsior", official_state_colors: []}}]
|
||||
},
|
||||
{
|
||||
state: "NJ",
|
||||
state_facts: [{
|
||||
pop: 9000000,
|
||||
facts: {
|
||||
state_motto: "Liberty and Prosperity",
|
||||
official_state_colors: ["jersey blue", "bluff"]
|
||||
}
|
||||
}]
|
||||
}
|
||||
];
|
||||
results = baseColl.aggregate(storedSourceAsSubPipe).toArray();
|
||||
assertArrayEq({actual: results, expected: expectedResults});
|
||||
|
||||
dropSearchIndex(addFieldsView, {name: "storedSourceIx"});
|
@ -156,8 +156,7 @@ StatusWith<stdx::unordered_set<NamespaceString>> validatePipeline(OperationConte
|
||||
|
||||
return liteParsedPipeline.getInvolvedNamespaces();
|
||||
}
|
||||
// TODO SERVER-93638 add comment for expected behavior of $lookup/$unionWith which might have
|
||||
// multiple backing collections.
|
||||
|
||||
NamespaceString findSourceCollectionNamespace(OperationContext* opCtx,
|
||||
std::shared_ptr<const CollectionCatalog> catalog,
|
||||
const NamespaceString& nss) {
|
||||
|
Loading…
Reference in New Issue
Block a user