2012-11-27 11:51:07 -05:00
|
|
|
// SEVER-7768 aggregate cmd shouldn't fail when $readPreference is specified
|
|
|
|
|
collection = 'server7768';
|
2013-05-20 00:28:32 -04:00
|
|
|
db[collection].drop();
|
2016-03-09 12:17:50 -05:00
|
|
|
db[collection].insert({foo: 1});
|
2012-12-18 13:26:26 -05:00
|
|
|
// Can't use aggregate helper here because we need to add $readPreference flag
|
2016-03-09 12:17:50 -05:00
|
|
|
res = db.runCommand({
|
|
|
|
|
'aggregate': collection,
|
|
|
|
|
'pipeline': [{'$project': {'_id': false, 'foo': true}}],
|
|
|
|
|
$readPreference: {'mode': 'primary'}
|
|
|
|
|
});
|
2012-11-27 11:51:07 -05:00
|
|
|
|
|
|
|
|
assert.commandWorked(res);
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(res.result, [{foo: 1}]);
|