2012-09-09 14:07:03 -07:00
|
|
|
// Providing the wrong number of fields in a pipeline stage specification triggers a parsing error.
|
|
|
|
|
// SERVER-6861
|
2012-12-18 13:26:26 -05:00
|
|
|
load('jstests/aggregation/extras/utils.js');
|
2012-09-09 14:07:03 -07:00
|
|
|
|
|
|
|
|
t = db.jstests_server6861;
|
|
|
|
|
t.drop();
|
|
|
|
|
|
|
|
|
|
t.save( { a:1 } );
|
|
|
|
|
|
|
|
|
|
function assertCode( code, expression ) {
|
2012-12-18 13:26:26 -05:00
|
|
|
assertErrorCode(t, expression, code);
|
2012-09-09 14:07:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function assertResult( result, expression ) {
|
2013-10-08 13:29:04 -04:00
|
|
|
assert.eq( result, t.aggregate( expression ).toArray() );
|
2012-09-09 14:07:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Correct number of fields.
|
|
|
|
|
assertResult( [ { a:1 } ], { $project:{ _id:0, a:1 } } );
|
|
|
|
|
|
|
|
|
|
// Incorrect number of fields.
|
|
|
|
|
assertCode( 16435, {} );
|
|
|
|
|
assertCode( 16435, { $project:{ _id:0, a:1 }, $group:{ _id:0 } } );
|
|
|
|
|
assertCode( 16435, { $project:{ _id:0, a:1 }, $group:{ _id:0 }, $sort:{ a:1 } } );
|
|
|
|
|
|
|
|
|
|
// Invalid stage specification.
|
|
|
|
|
assertCode( 16436, { $noSuchStage:{ a:1 } } );
|