Skip to content

Commit 695cb6f

Browse files
committedJul 28, 2018
test(document): repro #6779
1 parent 0ca947e commit 695cb6f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
 

‎test/document.test.js

+23
Original file line numberDiff line numberDiff line change
@@ -5729,6 +5729,29 @@ describe('document', function() {
57295729
});
57305730
});
57315731

5732+
it('doesnt double-call getters when using get() (gh-6779)', function() {
5733+
const schema = new Schema({
5734+
nested: {
5735+
arr: [{ key: String }]
5736+
}
5737+
});
5738+
5739+
schema.path('nested.arr.0.key').get(v => {
5740+
return 'foobar' + v;
5741+
});
5742+
5743+
const M = db.model('gh6779', schema);
5744+
const test = new M();
5745+
5746+
test.nested.arr.push({ key: 'value' });
5747+
test.nested.arr.push({ key: 'value2' });
5748+
5749+
assert.equal(test.get('nested.arr.0.key'), 'foobarvalue');
5750+
assert.equal(test.get('nested.arr.1.key'), 'foobarvalue2');
5751+
5752+
return Promise.resolve();
5753+
});
5754+
57325755
it('defaults should see correct isNew (gh-3793)', function() {
57335756
let isNew = [];
57345757
const TestSchema = new mongoose.Schema({

0 commit comments

Comments
 (0)
Please sign in to comment.