blob: 99e800e137a713889a35d395b94a3663518be13d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
/**
* Test that renaming a collection to itself is not allowed
*
* @tags: [
* requires_fcv_50,
* requires_non_retryable_commands,
* ]
*/
{
// Rename a collection to itself fails without loosing data
const sameColl = db['sameColl'];
assert.commandWorked(sameColl.insert({a: 1}));
const sameCollName = sameColl.toString().split('.')[1];
let dropTarget = true;
assert.commandFailedWithCode(sameColl.renameCollection(sameCollName, dropTarget),
ErrorCodes.IllegalOperation);
assert.eq(1, sameColl.countDocuments({}), "Rename a collection to itself must not lose data");
sameColl.drop(); // Drop collection to avoid reusing it in case of repeated executions
}
|