summaryrefslogtreecommitdiff
path: root/jstests/core/in4.js
blob: e916ca7c82d933fa24163a79162136225e4988d0 (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
36
37
// @tags: [requires_non_retryable_writes]

// 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.createIndex({key: 1});
doTest();