blob: 71e9f8eadb9e3235c15cde73941f99f91c65a112 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
// Tests that SERVER-11374 is fixed: specifically, that indexes cannot
// be created on fields that begin with '$' but are not part of DBRefs
// and that indexes cannot be created on field paths that contain empty
// fields.
var coll = db.jstests_indexp;
// Empty field checks.
assert.commandFailed(coll.ensureIndex({'a..b': 1}));
assert.commandFailed(coll.ensureIndex({'.a': 1}));
assert.commandFailed(coll.ensureIndex({'a.': 1}));
assert.commandFailed(coll.ensureIndex({'.': 1}));
assert.commandFailed(coll.ensureIndex({'': 1}));
assert.commandWorked(coll.ensureIndex({'a.b': 1}));
// '$'-prefixed field checks.
assert.commandFailed(coll.ensureIndex({'$a': 1}));
assert.commandFailed(coll.ensureIndex({'a.$b': 1}));
assert.commandFailed(coll.ensureIndex({'$db': 1}));
assert.commandWorked(coll.ensureIndex({'a$ap': 1})); // $ in middle is ok
assert.commandWorked(coll.ensureIndex({'a.$id': 1})); // $id/$db/$ref are execptions
coll.dropIndexes();
|