Files
mongo/jstests/core/null2.js
Siyuan Zhou 3660343e0b SERVER-12127 migrate js tests to jscore suite when not related to writes
Migrate js tests starting from j-z.
Include SERVER-12920 Update use_power_of_2.js

Signed-off-by: Matt Kangas <matt.kangas@mongodb.com>
2014-03-03 22:54:10 -05:00

46 lines
985 B
JavaScript

t = db.null2;
t.drop();
t.insert( { _id : 1, a : [ { b : 5 } ] } );
t.insert( { _id : 2, a : [ {} ] } );
t.insert( { _id : 3, a : [] } );
t.insert( { _id : 4, a : [ {}, { b : 5 } ] } );
t.insert( { _id : 5, a : [ 5, { b : 5 } ] } );
function doQuery( query ) {
printjson( query );
t.find( query ).forEach(
function(z) {
print( "\t" + tojson(z) );
}
);
return t.find( query ).count();
}
function getIds( query ) {
var ids = []
t.find( query ).forEach(
function(z) {
ids.push( z._id );
}
);
return ids;
}
theQueries = [ { "a.b" : null }, { "a.b" : { $in : [ null ] } } ];
for ( var i=0; i < theQueries.length; i++ ) {
assert.eq( 2, doQuery( theQueries[i] ) );
assert.eq( [2,4], getIds( theQueries[i] ) );
}
t.ensureIndex( { "a.b" : 1 } )
for ( var i=0; i < theQueries.length; i++ ) {
assert.eq( 2, doQuery( theQueries[i] ) );
assert.eq( [2,4], getIds( theQueries[i] ) );
}