blob: 8698195d6c4b09c7b7d7133ca935caa884fb0016 (
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
// @tags: [
// assumes_unsharded_collection,
// requires_fastcount,
// requires_javascript,
// requires_non_retryable_commands,
// sbe_incompatible,
// ]
t = db.jstests_js3;
debug = function(s) {
// printjson( s );
};
for (z = 0; z < 2; z++) {
debug(z);
t.drop();
if (z > 0) {
t.createIndex({_id: 1});
t.createIndex({i: 1});
}
for (i = 0; i < 1000; i++)
t.save({
i: i,
z: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
});
assert(2 == t.find({
$where: function() {
return obj.i == 7 || obj.i == 8;
}
}).length());
assert.eq(1000, t.count());
// NPE test
var ok = false;
try {
var x = t.find({
$where: function() {
asdf.asdf.f.s.s();
}
});
debug(x.length());
debug(tojson(x));
} catch (e) {
ok = true;
}
debug(ok);
assert(ok);
t.createIndex({z: 1});
t.createIndex({q: 1});
debug("before indexed find");
arr = t.find({
$where: function() {
return obj.i == 7 || obj.i == 8;
}
}).toArray();
debug(arr);
assert.eq(2, arr.length);
debug("after indexed find");
for (i = 1000; i < 2000; i++)
t.save({
i: i,
z: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
});
assert(t.find().count() == 2000);
assert(t.validate().valid);
debug("done iter");
}
t.drop();
|