Skip to content

Commit

Permalink
test(document): repro #8201
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Oct 1, 2019
1 parent 43b63ae commit 84619be
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions test/document.test.js
Expand Up @@ -8081,4 +8081,37 @@ describe('document', function() {
doc.init(data);
require('util').inspect(doc.subdocs);
});

it('set() merge option with single nested (gh-8201)', function() {
const AddressSchema = Schema({
street: { type: String, required: true },
city: { type: String, required: true }
});
const PersonSchema = Schema({
name: { type: String, required: true },
address: { type: AddressSchema, required: true }
});
const Person = db.model('gh8201', PersonSchema);

return co(function*() {
yield Person.create({
name: 'John Smith',
address: {
street: 'Real Street',
city: 'Somewhere'
}
});

const person = yield Person.findOne();
person.set({
name: 'John Smythe',
address: { street: 'Fake Street' } },
undefined,
{ merge: true }
);

assert.equal(person.address.city, 'Somewhere');
yield person.save();
});
});
});

0 comments on commit 84619be

Please sign in to comment.