diff options
author | Ian Boros <ian.boros@mongodb.com> | 2019-12-12 23:41:34 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-12-12 23:41:34 +0000 |
commit | e699ae35a04c421398adb76002546da720c25673 (patch) | |
tree | 5552b2f2148931409409d46c03dba98d8316ac89 /jstests | |
parent | a02960827dd9d145292eb32d9745cdd52001ebda (diff) | |
download | mongo-e699ae35a04c421398adb76002546da720c25673.tar.gz |
SERVER-26066 Fix dependency analysis for projections with expressions on dotted fields
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/aggregation/sources/project/project_dotted_paths.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/jstests/aggregation/sources/project/project_dotted_paths.js b/jstests/aggregation/sources/project/project_dotted_paths.js new file mode 100644 index 00000000000..cf730861e5e --- /dev/null +++ b/jstests/aggregation/sources/project/project_dotted_paths.js @@ -0,0 +1,26 @@ +// Test that projection of dotted paths which happens in the "agg" layer works correctly. See +// SERVER-26066 for details. +(function() { +const coll = db.project_dotted_paths; +coll.drop(); + +assert.commandWorked(coll.insert({a: [1, {b: 2}, 3, {}]})); + +function checkResultsConsistent(projection, expectedResults) { + const aggResults = coll.aggregate([{$project: projection}]).toArray(); + const aggNoPushdownResults = + coll.aggregate([{$_internalInhibitOptimization: {}}, {$project: projection}]).toArray(); + const findResults = coll.find({}, projection).toArray(); + + assert.eq(aggResults, expectedResults); + assert.eq(aggNoPushdownResults, expectedResults); + assert.eq(findResults, expectedResults); +} + +checkResultsConsistent({"a": {$literal: "newValue"}, _id: 0}, [{a: "newValue"}]); +checkResultsConsistent({"a.b": {$literal: "newValue"}, _id: 0}, + [{a: [{b: "newValue"}, {b: "newValue"}, {b: "newValue"}, {b: "newValue"}]}]); +checkResultsConsistent({"a.b.c": {$literal: "newValue"}, _id: 0}, [ + {a: [{b: {c: "newValue"}}, {b: {c: "newValue"}}, {b: {c: "newValue"}}, {b: {c: "newValue"}}]} +]); +})(); |