Skip to content

Commit

Permalink
Merge pull request #13933 from Automattic/IslandRhythms/undo-id
Browse files Browse the repository at this point in the history
undo id change
  • Loading branch information
vkarpov15 authored Oct 4, 2023
2 parents a57bb72 + baeba70 commit b1a2e04
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 32 deletions.
4 changes: 0 additions & 4 deletions lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1060,10 +1060,6 @@ Document.prototype.$set = function $set(path, val, type, options) {
[path, val] = [val, path];
}

if ('_id' in path && 'id' in path) {
delete path.id;
}

prefix = val ? val + '.' : '';
keys = getKeysInSchemaOrder(this.$__schema, path);

Expand Down
28 changes: 0 additions & 28 deletions test/document.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12410,34 +12410,6 @@ describe('document', function() {
assert.strictEqual(nestedProjectionDoc.sub.propertyA, 'A');
});

it('should ignore `id` if the object contains `id` and `_id` as keys (gh-13762)', async function() {
const testSchema = new Schema({
_id: {
type: Number
}
});
const Test = db.model('Test', testSchema);

const x = new Test({ _id: 1, id: 2 });
await x.save();
const fromDb = await Test.findById(x._id).lean();
assert.equal(fromDb._id, 1);
});
it('should ignore `id` if settings with an object that contains `_id` and `id` (gh-13672)', async function() {
const testSchema = new Schema({
_id: {
type: Number
}
});
const Test = db.model('Test', testSchema);

const x = new Test();
x.set('_id', { _id: 1, id: 2 });
await x.save();

const fromDb = await Test.findById(x._id).lean();
assert.equal(fromDb._id, 1);
});
it('handles bigint (gh-13791)', async function() {
const testSchema = new mongoose.Schema({
n: Number,
Expand Down

0 comments on commit b1a2e04

Please sign in to comment.