2012-07-25 10:47:24 -04:00
|
|
|
// ensure strings containing null characters dont end at that null
|
2012-08-03 12:35:18 -04:00
|
|
|
|
2012-07-25 10:47:24 -04:00
|
|
|
c = db.s6556;
|
|
|
|
|
c.drop();
|
|
|
|
|
|
|
|
|
|
c.save({foo:"as\0df"});
|
|
|
|
|
|
|
|
|
|
// compare the whole string, they should match
|
2013-10-08 13:29:04 -04:00
|
|
|
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as\0df", "$foo"]}}}).toArray(), [{matches:true}]);
|
2012-07-25 10:47:24 -04:00
|
|
|
// compare with the substring containing only the up to the null, they should not match
|
2013-10-08 13:29:04 -04:00
|
|
|
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as\0df", {$substr:["$foo",0,3]}]}}}).toArray(), [{matches:false}]);
|
2012-07-25 10:47:24 -04:00
|
|
|
// partial the other way shouldnt work either
|
2013-10-08 13:29:04 -04:00
|
|
|
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as", "$foo"]}}}).toArray(), [{matches:false}]);
|
2012-07-25 10:47:24 -04:00
|
|
|
// neither should one that differs after the null
|
2013-10-08 13:29:04 -04:00
|
|
|
assert.eq(c.aggregate({$project: {_id: 0, matches: {$eq:["as\0de", "$foo"]}}}).toArray(), [{matches:false}]);
|
2012-07-25 10:47:24 -04:00
|
|
|
// should assert on fieldpaths with a null
|
2013-03-13 13:02:27 -07:00
|
|
|
assert.throws( function() {
|
|
|
|
|
c.aggregate({$project: {_id: 0, matches: {$eq:["as\0df", "$f\0oo"]}}})
|
2013-10-08 13:29:04 -04:00
|
|
|
});
|