summaryrefslogtreecommitdiff
path: root/jstests/core/nestedobj1.js
blob: 45ef0c530d4c798b075cb44633c2264e04f31534 (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
//SERVER-5127, SERVER-5036

function makeNestObj(depth){
    toret = { a : 1};

    for(i = 1; i < depth; i++){
        toret = {a : toret};
    }

    return toret;
}

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

t.ensureIndex({a:1});

n = 1;
while ( true ) {
    var before = t.count();
    t.insert( { _id : n, a : makeNestObj(n) } );
    var after = t.count();
    if ( before == after )
        break;
    n++;
}

assert( n > 30, "not enough n: " + n );

assert.eq( t.count(), t.find( { _id : { $gt : 0 } } ).hint( { a : 1 } ).itcount() );