Files
mongo/jstests/aggregation/bugs/server6238.js
Mathias Stearn 68f6dcd2c3 SERVER-6649 have agg helper throw exceptions and fix tests accordingly
Most of this was done by Samantha Ritter. Thanks!
2012-12-18 15:34:56 -05:00

16 lines
529 B
JavaScript

// do not allow creation of fields with a $ prefix
load('jstests/aggregation/extras/utils.js');
c = db.c;
c.drop();
c.insert({a:1});
// assert that we get the proper error in both $project and $group
assertErrorCode(c, {$project:{$a:"$a"}}, 16404);
assertErrorCode(c, {$project:{a:{$b: "$a"}}}, 15999);
assertErrorCode(c, {$project:{a:{"$b": "$a"}}}, 15999);
assertErrorCode(c, {$project:{'a.$b':"$a"}}, 16410);
assertErrorCode(c, {$group:{_id: "$_id", $a:"$a"}}, 15950);
assertErrorCode(c, {$group:{_id: {$a:"$a"}}}, 15999);