summaryrefslogtreecommitdiff
path: root/jstests/in8.js
blob: 5e7e587629ff759d170a1a2529f0f0e73c6edbb7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// SERVER-2829 Test arrays matching themselves within a $in expression.

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

t.save( {key: [1]} );
t.save( {key: ['1']} );
t.save( {key: [[2]]} );

function doTest() { 
    assert.eq( 1, t.count( {key:[1]} ) );
    assert.eq( 1, t.count( {key:{$in:[[1]]}} ) );
    assert.eq( 1, t.count( {key:{$in:[[1]],$ne:[2]}} ) );
    assert.eq( 1, t.count( {key:{$in:[['1']],$type:2}} ) );
    assert.eq( 1, t.count( {key:['1']} ) );
    assert.eq( 1, t.count( {key:{$in:[['1']]}} ) );
    assert.eq( 1, t.count( {key:[2]} ) );
    assert.eq( 1, t.count( {key:{$in:[[2]]}} ) );
} 

doTest(); 
t.ensureIndex( {key:1} ); 
doTest();