Files
mongo/jstests/aggregation/bugs/server75670.js
2023-08-06 20:48:04 +00:00

26 lines
648 B
JavaScript

// SERVER-75670 Incorrect projection pushdown caused by dependency analysis for multiple $project
// stages on the same dotted path.
import {resultsEq} from "jstests/aggregation/extras/utils.js";
const collName = jsTestName();
const coll = db.getCollection(collName);
coll.drop();
assert.commandWorked(coll.insert([
{_id: 1, obj: {str: "abc"}},
{_id: 2, obj: {}},
{_id: 3, str: "abc"},
]));
assert(resultsEq(
[
{_id: 1, obj: {}},
{_id: 2, obj: {}},
{_id: 3},
],
coll.aggregate([
{$project: {"obj.str": 0}},
{$project: {"obj.str": 1}},
])
.toArray(),
));