Files
mongo/jstests/aggregation/bugs/server6570.js
Matt Dannenberg d3b12c40a9 SERVER-6570 disallow strings in $add in aggro
also started SERVER-6166 (ints overflowing to long in math) by doing the add portion
redo testall.js p20 when SERVER-6195 is done
2012-07-27 14:30:40 -04:00

13 lines
747 B
JavaScript

// ensure $add asserts on string
c = db.s6570;
c.drop();
c.save({x:17, y:"foo"});
assert.eq(c.aggregate({$project:{string_fields : { $add:[3, "$y", 4, "$y"] }}}).code, 16416);
assert.eq(c.aggregate({$project:{number_fields : { $add:["a", "$x", "b", "$x"] }}}).code, 16416);
assert.eq(c.aggregate({$project:{all_strings : { $add:["c", "$y", "d", "$y"] }}}).code, 16416);
assert.eq(c.aggregate({$project:{potpourri_1 : { $add:[5, "$y", "e", "$x"] }}}).code, 16416);
assert.eq(c.aggregate({$project:{potpourri_2 : { $add:[6, "$x", "f", "$y"] }}}).code, 16416);
assert.eq(c.aggregate({$project:{potpourri_3 : { $add:["g", "$y", 7, "$x"] }}}).code, 16416);
assert.eq(c.aggregate({$project:{potpourri_4 : { $add:["h", "$x", 8, "$y"] }}}).code, 16416);