Files
mongo/jstests/aggregation/optimization/double_project_dep_analysis.js
Zac 591928c619 SERVER-108478 JS formatted by prettier and remove clang-format (#39656)
GitOrigin-RevId: 6c8f6aded47f260aa4f7c231b17dae3302cb1e04
2025-08-21 17:27:09 +00:00

23 lines
612 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(),
),
);