Skip to content

Commit 9df01d4

Browse files
committed
NODE-899 Avoid any cyclic dependency so marshalling does not break if using JSON.stringify
1 parent 2af5994 commit 9df01d4

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

lib/collection.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -899,7 +899,7 @@ var updateOne = function(self, filter, update, options, callback) {
899899

900900
// Fix for NODE-899, backward compatibility with legacy format
901901
if(r.upsertedId) {
902-
r.upsertedId._id = r.upsertedId;
902+
r.upsertedId._id = new ObjectID(r.upsertedId.id);
903903
}
904904

905905
if(callback) callback(null, r);

test/functional/crud_api_tests.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ exports['should correctly execute update methods using crud api'] = {
538538
test.ok(r.upsertedId != null);
539539
test.equal('ObjectID', r.upsertedId._bsontype);
540540
test.equal('ObjectID', r.upsertedId._id._bsontype);
541+
test.equal(r.upsertedId.toHexString(), r.upsertedId._id.toHexString());
541542

542543
db.collection('t3_2').updateOne({ c: 1 }
543544
, { $set: { a: 1 } }, function(err, r) {

0 commit comments

Comments
 (0)