diff options
Diffstat (limited to 'jstests/all5.js')
-rw-r--r-- | jstests/all5.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/jstests/all5.js b/jstests/all5.js new file mode 100644 index 00000000000..a5d9e312292 --- /dev/null +++ b/jstests/all5.js @@ -0,0 +1,28 @@ +// Test $all/$elemMatch/null matching - SERVER-4517 + +t = db.jstests_all5; +t.drop(); + +function checkMatch( doc ) { + t.drop(); + t.save( doc ); + assert.eq( 1, t.count( {a:{$elemMatch:{b:null}}} ) ); + assert.eq( 1, t.count( {a:{$all:[{$elemMatch:{b:null}}]}} ) ); +} + +function checkNoMatch( doc ) { + t.drop(); + t.save( doc ); + assert.eq( 0, t.count( {a:{$all:[{$elemMatch:{b:null}}]}} ) ); +} + +checkNoMatch( {} ); +checkNoMatch( {a:1} ); + +checkNoMatch( {a:[]} ); +checkNoMatch( {a:[1]} ); + +checkMatch( {a:[{}]} ); +checkMatch( {a:[{c:1}]} ); +checkMatch( {a:[{b:null}]} ); +checkNoMatch( {a:[{b:1}]}, 0 ); |