Skip to content

Commit 0922d78

Browse files
committedNov 4, 2015
fix; call toObject() when setting single embedded schema to doc (Fix #3535)
1 parent ce11be0 commit 0922d78

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed
 

‎lib/document.js

+5
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,11 @@ Document.prototype.set = function(path, val, type, options) {
503503
this.set(path[key], prefix + key, constructing);
504504
} else if (strict) {
505505
if ('real' === pathtype || 'virtual' === pathtype) {
506+
// Check for setting single embedded schema to document (gh-3535)
507+
if (this.schema.paths[pathName] &&
508+
this.schema.paths[pathName].$isSingleNested) {
509+
path[key] = path[key].toObject({ virtuals: false });
510+
}
506511
this.set(prefix + key, path[key], constructing);
507512
} else if (pathtype === 'nested' && path[key] instanceof Document) {
508513
this.set(prefix + key,

0 commit comments

Comments
 (0)
Please sign in to comment.