summaryrefslogtreecommitdiff
path: root/jstests/core/long_index_rename.js
blob: df304b777ad16cced4ebe439401648701e09c4b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// SERVER-7720 Building an index with a too-long name is acceptable since 4.2.
// Previously, we would disallow index creation with with too long a name.
// @tags: [requires_non_retryable_commands, assumes_unsharded_collection]

(function() {
'use strict';

const coll = db.long_index_rename;
coll.drop();

for (let i = 1; i < 10; i++) {
    coll.save({a: i});
}

// Beginning with 4.2, index namespaces longer than 127 characters are acceptable.
assert.commandWorked(coll.createIndex({b: 1}, {name: 'a'.repeat(8192)}));

// Before 4.2, index namespace lengths were checked while renaming collections.
const dest = db.long_index_rename2;
dest.drop();
assert.commandWorked(coll.renameCollection(dest.getName()));
})();