summaryrefslogtreecommitdiff
path: root/jstests/core/query/regex/regex_not_id.js
blob: a38b452d423b3fadd4701b21faa2aac76280526a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
// don't allow regex as _id: SERVER-9502

var testColl = db.regex_not_id;
testColl.drop();

assert.commandWorked(testColl.insert({_id: "ABCDEF1"}));

// Should be an error.
assert.writeError(testColl.insert({_id: /^A/}));

// _id doesn't have to be first; still disallowed
assert.writeError(testColl.insert({xxx: "ABCDEF", _id: /ABCDEF/}));