-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into vkarpov15/gh-14719
- Loading branch information
Showing
3 changed files
with
41 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12805,7 +12805,7 @@ describe('document', function() { | |
await user.save(); | ||
await TestModel.deleteOne({ userId }); | ||
|
||
assert.equal(Object.keys(TestModel.schema.subpaths).length, 3); | ||
assert.ok(Object.keys(TestModel.schema.subpaths).length <= 3); | ||
}); | ||
|
||
it('handles embedded discriminators defined using Schema.prototype.discriminator (gh-13898)', async function() { | ||
|
@@ -13552,6 +13552,36 @@ describe('document', function() { | |
assert.ok(blogPost.comment.jsonField.isDirectModified('fieldA')); | ||
}); | ||
|
||
it('avoids leaving subdoc _id in default state when setting subdocument to same value (gh-14722)', async function() { | ||
const getUser = () => ({ | ||
_id: new mongoose.Types.ObjectId('66852317541ef0e22ae5214c'), | ||
name: 'test1', | ||
email: '[email protected]' | ||
}); | ||
|
||
const updateInfoSchema = new mongoose.Schema({ | ||
name: { | ||
type: String, required: true | ||
}, | ||
email: { | ||
type: String, | ||
required: true | ||
} | ||
}, { | ||
versionKey: false | ||
}); | ||
const schema = new mongoose.Schema({ name: String, updater: updateInfoSchema }); | ||
|
||
const TestModel = db.model('Test', schema); | ||
const { _id } = await TestModel.create({ name: 'taco', updater: getUser() }); | ||
const doc = await TestModel.findById(_id).orFail(); | ||
|
||
doc.name = 'taco-edit'; | ||
doc.updater = getUser(); | ||
assert.deepStrictEqual(doc.getChanges(), { $set: { name: 'taco-edit' } }); | ||
assert.ok(!doc.$isDefault('updater._id')); | ||
}); | ||
|
||
it('$clearModifiedPaths (gh-14268)', async function() { | ||
const schema = new Schema({ | ||
name: String, | ||
|