2009-10-08 11:12:08 -04:00
|
|
|
|
|
|
|
|
t = db.null1;
|
|
|
|
|
t.drop();
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.save({x: 1});
|
|
|
|
|
t.save({x: null});
|
2009-10-08 11:12:08 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(1, t.find({x: null}).count(), "A");
|
|
|
|
|
assert.eq(1, t.find({x: {$ne: null}}).count(), "B");
|
2009-10-08 11:12:08 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.ensureIndex({x: 1});
|
2009-10-08 11:12:08 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(1, t.find({x: null}).count(), "C");
|
|
|
|
|
assert.eq(1, t.find({x: {$ne: null}}).count(), "D");
|
2013-05-19 19:44:29 -04:00
|
|
|
|
|
|
|
|
// -----
|
|
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
assert.eq(2, t.find({y: null}).count(), "E");
|
2013-05-19 19:44:29 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.ensureIndex({y: 1});
|
|
|
|
|
assert.eq(2, t.find({y: null}).count(), "E");
|
2013-05-19 19:44:29 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.dropIndex({y: 1});
|
2013-05-19 19:44:29 -04:00
|
|
|
|
2016-03-09 12:17:50 -05:00
|
|
|
t.ensureIndex({y: 1}, {sparse: true});
|
|
|
|
|
assert.eq(2, t.find({y: null}).count(), "E");
|