summaryrefslogtreecommitdiff
path: root/jstests/indext.js
blob: e418dc2e95948333084d32487c45e01d1679a865 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Sparse indexes with arrays SERVER-3216

t = db.jstests_indext;
t.drop();

t.ensureIndex( {'a.b':1}, {sparse:true} );
t.save( {a:[]} );
t.save( {a:1} );
assert.eq( 0, t.find().hint( {'a.b':1} ).itcount() );
assert.eq( 0, t.find().hint( {'a.b':1} ).explain().nscanned );

t.ensureIndex( {'a.b':1,'a.c':1}, {sparse:true} );
t.save( {a:[]} );
t.save( {a:1} );
assert.eq( 0, t.find().hint( {'a.b':1,'a.c':1} ).itcount() );
assert.eq( 0, t.find().hint( {'a.b':1,'a.c':1} ).explain().nscanned );

t.save( {a:[{b:1}]} );
t.save( {a:1} );
assert.eq( 1, t.find().hint( {'a.b':1,'a.c':1} ).itcount() );
assert.eq( 1, t.find().hint( {'a.b':1,'a.c':1} ).explain().nscanned );