Skip to content

Commit b1a2e04

Browse files
authored
Merge pull request #13933 from Automattic/IslandRhythms/undo-id
undo id change
2 parents a57bb72 + baeba70 commit b1a2e04

File tree

2 files changed

+0
-32
lines changed

2 files changed

+0
-32
lines changed

lib/document.js

-4
Original file line numberDiff line numberDiff line change
@@ -1060,10 +1060,6 @@ Document.prototype.$set = function $set(path, val, type, options) {
10601060
[path, val] = [val, path];
10611061
}
10621062

1063-
if ('_id' in path && 'id' in path) {
1064-
delete path.id;
1065-
}
1066-
10671063
prefix = val ? val + '.' : '';
10681064
keys = getKeysInSchemaOrder(this.$__schema, path);
10691065

test/document.test.js

-28
Original file line numberDiff line numberDiff line change
@@ -12410,34 +12410,6 @@ describe('document', function() {
1241012410
assert.strictEqual(nestedProjectionDoc.sub.propertyA, 'A');
1241112411
});
1241212412

12413-
it('should ignore `id` if the object contains `id` and `_id` as keys (gh-13762)', async function() {
12414-
const testSchema = new Schema({
12415-
_id: {
12416-
type: Number
12417-
}
12418-
});
12419-
const Test = db.model('Test', testSchema);
12420-
12421-
const x = new Test({ _id: 1, id: 2 });
12422-
await x.save();
12423-
const fromDb = await Test.findById(x._id).lean();
12424-
assert.equal(fromDb._id, 1);
12425-
});
12426-
it('should ignore `id` if settings with an object that contains `_id` and `id` (gh-13672)', async function() {
12427-
const testSchema = new Schema({
12428-
_id: {
12429-
type: Number
12430-
}
12431-
});
12432-
const Test = db.model('Test', testSchema);
12433-
12434-
const x = new Test();
12435-
x.set('_id', { _id: 1, id: 2 });
12436-
await x.save();
12437-
12438-
const fromDb = await Test.findById(x._id).lean();
12439-
assert.equal(fromDb._id, 1);
12440-
});
1244112413
it('handles bigint (gh-13791)', async function() {
1244212414
const testSchema = new mongoose.Schema({
1244312415
n: Number,

0 commit comments

Comments
 (0)