summaryrefslogtreecommitdiff
path: root/jstests/core/dbref4.js
blob: d46484972181511d897a900d88982a5880823a90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Fix for SERVER-32072
//
// Ensures round-trippability of int ids in DBRef's after a save/restore

(function() {
    "use strict";

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

    coll.insert({
        "refInt": DBRef("DBRef", NumberInt(1), "Ref"),
    });

    // we inserted something with an int
    assert(coll.findOne({'refInt.$id': {$type: 16}}));

    var doc = coll.findOne();
    doc.x = 1;
    coll.save(doc);

    // after pulling it back and saving it again, still has an int
    assert(coll.findOne({'refInt.$id': {$type: 16}}));
})();