Skip to content

Commit

Permalink
test: repro #8274
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Oct 31, 2019
1 parent 0d057fe commit 78d5c4b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/model.discriminator.test.js
Expand Up @@ -1485,5 +1485,28 @@ describe('model', function() {
assert.equal(e.get('lookups.0.name'), 'address2');
assert.equal(e.lookups[0].name, 'address2');
});

it('_id: false in discriminator nested schema (gh-8274)', function() {
const schema = new Schema({
operations: {
type: [{ _id: Number, action: String }]
}
});
schema.path('operations').discriminator('gh8274_test', new Schema({
pitchPath: Schema({
_id: Number,
path: [{ _id: false, x: Number, y: Number }]
})
}));
const Model = db.model('gh8274', schema);

const doc = new Model();
doc.operations.push({
_id: 42,
__t: 'gh8274_test',
pitchPath: { path: [{ x: 1, y: 2 }] }
});
assert.strictEqual(doc.operations[0].pitchPath.path[0]._id, void 0);
});
});
});

0 comments on commit 78d5c4b

Please sign in to comment.