Files
mongo/jstests/aggregation/bugs/server6556.js
Mathias Stearn 061a086641 SERVER-10165 aggregate() shell helper now returns a cursor
The actual change is in src/mongo/shell/collection.js with the remaining changes
to adjust tests to the new api.

The "ideal" arguments are now an array of pipeline ops and an optional object
with extra top-level options for the command (such as {explain: true}. For
backwards compatibility, we still support the varargs style where each argument
is a pipeline stage, but there is no way to specify extra parameters in this
mode.
2013-10-08 17:35:02 -04:00

20 lines
950 B
JavaScript

// ensure strings containing null characters dont end at that null
c = db.s6556;
c.drop();
c.save({foo:"as\0df"});
// compare the whole string, they should match
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as\0df", "$foo"]}}}).toArray(), [{matches:true}]);
// compare with the substring containing only the up to the null, they should not match
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as\0df", {$substr:["$foo",0,3]}]}}}).toArray(), [{matches:false}]);
// partial the other way shouldnt work either
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as", "$foo"]}}}).toArray(), [{matches:false}]);
// neither should one that differs after the null
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as\0de", "$foo"]}}}).toArray(), [{matches:false}]);
// should assert on fieldpaths with a null
assert.throws( function() {
c.aggregate({$project: {_id: 0, matches: {$eq:["as\0df", "$f\0oo"]}}})
});