|
SERVER-25120 introduced a concept of generated fields in the context of pipeline dependency analysis. This allowed us to avoid pushing down fields into the PlanStage/find layer which were actually introduced (generated) later in the pipeline. The implementation treats exclusion projections as fields which are generated. The problem with this is that if we later has an inclusion projection on the same field, we omit that field as a dependency for the pipeline and don't pushdown the field to the find layer. This is ok for non-dotted paths, for yields different results for dotted paths.
db.c.insert({"_id": 1, "obj": {"str": "abc"}})
|
db.c.aggregate([{$project: {"obj.str": 0}}, {$project: {"obj.str": 1}}])
|
|
// Before SERVER-25120
|
[{_id: 1, obj: {}}]
|
|
// After SERVER-25120
|
[{_id: 1}]
|
We need to pushdown 'obj.str' into the find layer to maintain correct query results.
|