summaryrefslogtreecommitdiff
path: root/jstests/regex_limit.js
blob: e05dae8ab8b2dd78a1ec2f60238a590b69a1a7d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var t = db.regex_limit;
t.drop();

var repeatStr = function(str, n){
  return new Array(n + 1).join(str);
};

t.insert({ z: repeatStr('c', 100000) });

var maxOkStrLen = repeatStr('c', 32764);
var strTooLong = maxOkStrLen + 'c';

assert(t.findOne({ z: { $regex: maxOkStrLen }}) != null);
assert.throws(function() {
    t.findOne({ z: { $regex: strTooLong }});
});

assert(t.findOne({ z: { $in: [ new RegExp(maxOkStrLen) ]}}) != null);
assert.throws(function() {
    t.findOne({ z: { $in: [ new RegExp(strTooLong) ]}});
});