summaryrefslogtreecommitdiff
path: root/jstests/core/rename_change_target_type.js
blob: 25fbcfb0f01965e5bf1e0c26670905408a4e6976 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// Test that a rename that overwrites its destination with an equivalent value of a different type
// updates the type of the destination (SERVER-32109).
(function() {
    "use strict";

    let coll = db.rename_change_target_type;
    coll.drop();

    assert.writeOK(coll.insert({to: NumberLong(100), from: 100}));
    assert.writeOK(coll.update({}, {$rename: {from: "to"}}));

    let aggResult = coll.aggregate([{$project: {toType: {$type: "$to"}}}]).toArray();
    assert.eq(aggResult.length, 1);
    assert.eq(aggResult[0].toType, "double", "Incorrect type resulting from $rename");
})();