Skip to content

Commit 84619be

Browse files
committed
test(document): repro #8201
1 parent 43b63ae commit 84619be

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

test/document.test.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8081,4 +8081,37 @@ describe('document', function() {
80818081
doc.init(data);
80828082
require('util').inspect(doc.subdocs);
80838083
});
8084+
8085+
it('set() merge option with single nested (gh-8201)', function() {
8086+
const AddressSchema = Schema({
8087+
street: { type: String, required: true },
8088+
city: { type: String, required: true }
8089+
});
8090+
const PersonSchema = Schema({
8091+
name: { type: String, required: true },
8092+
address: { type: AddressSchema, required: true }
8093+
});
8094+
const Person = db.model('gh8201', PersonSchema);
8095+
8096+
return co(function*() {
8097+
yield Person.create({
8098+
name: 'John Smith',
8099+
address: {
8100+
street: 'Real Street',
8101+
city: 'Somewhere'
8102+
}
8103+
});
8104+
8105+
const person = yield Person.findOne();
8106+
person.set({
8107+
name: 'John Smythe',
8108+
address: { street: 'Fake Street' } },
8109+
undefined,
8110+
{ merge: true }
8111+
);
8112+
8113+
assert.equal(person.address.city, 'Somewhere');
8114+
yield person.save();
8115+
});
8116+
});
80848117
});

0 commit comments

Comments
 (0)