Files
mongo/jstests/core/query/dbref/dbref4.js
Steve McClure 1ffbc6c2e9 SERVER-109432: Autofix JS var usage to favor let (#40637)
GitOrigin-RevId: 9674b7db36a0f3f650d39c1e3fb2ad6ff2141cfb
2025-08-28 19:21:01 +00:00

21 lines
466 B
JavaScript

// Fix for SERVER-32072
//
// Ensures round-trippability of int ids in DBRef's after a save/restore
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}}));
let 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}}));