Files
mongo/jstests/core/dbref4.js
Jason Carey edebe4d632 SERVER-32072 Always roundtrip dbrefs in the shell
dbrefs in the shell can see silent casts from int -> float due to a lack
of special case logic that regular bson objects receive.

For a fix, hook up the special lookup routines in js bsoninfo type into
the js dbrefinfo types.
2018-02-01 10:52:11 -05:00

25 lines
553 B
JavaScript

// 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}}));
})();