Files
mongo/jstests/aggregation/bugs/server7768.js
David Storch 20d43f94ce SERVER-59302 Remove support in client code for commands wrapped with $query
The shell and internal client used to upconvert commands
wrapped in a "$query" or "query" to a well-formed OP_MSG.
This behavior is a holdover from when OP_QUERY was supported
and is no longer needed.
2022-11-17 20:02:18 +00:00

23 lines
691 B
JavaScript

// SEVER-7768 aggregate cmd shouldn't fail when $readPreference is specified.
//
// @tags: [
// # This test sets a read preference itself and does not expect it to be overridden.
// assumes_read_preference_unchanged,
// ]
(function() {
'use strict';
let collection = db.server7768;
collection.drop();
assert.commandWorked(collection.insert({foo: 1}));
// Can't use aggregate helper here because we need to add $readPreference flag.
let res = db.runCommand({
aggregate: collection.getName(),
pipeline: [{$project: {_id: false, foo: true}}],
$readPreference: {mode: 'primary'},
cursor: {}
});
assert.commandWorked(res);
assert.eq(res.cursor.firstBatch, [{foo: 1}]);
}());