summaryrefslogtreecommitdiff
path: root/jstests/in9.js
blob: 34cefb8278ad4b9c3d43822f76dfd396f01557eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// SERVER-2343 Test $in empty array matching.

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

function someData() {
 	t.remove();   
    t.save( {key: []} ); 
}

function moreData() {
 	someData();
    t.save( {key: [1]} ); 
    t.save( {key: ['1']} ); 
    t.save( {key: null} ); 
    t.save( {} );     
}

function check() {
    assert.eq( 1, t.count( {key:[]} ) );
    assert.eq( 1, t.count( {key:{$in:[[]]}} ) );    
}

function doTest() {
    someData();
    check();
    moreData();
    check();
} 

doTest(); 

// SERVER-1943 not fixed yet
t.ensureIndex( {key:1} ); 
doTest();