Skip to content

Commit

Permalink
test(document): repro #4991
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Dec 6, 2017
1 parent 23c8dd0 commit 7e4077d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/model.discriminator.querying.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,29 @@ describe('model', function() {
catch(done);
});

it('doesnt exclude field if slice (gh-4991)', function(done) {
var baseSchema = new mongoose.Schema({
propA: { type: String, default: 'default value' },
array: [{type: String}]
});

var Base = db.model('gh4991_A', baseSchema);
var discriminatorSchema = new mongoose.Schema({
propB: { type: String}
});
var Discriminator = Base.discriminator('gh4991_A1', discriminatorSchema);

var obj = { propA: 'Hi', propB: 'test', array: ['a', 'b'] };
Discriminator.create(obj, function(error, doc) {
assert.ifError(error);
Base.find().slice('array', 1).exec(function(error, docs) {
assert.equal(docs.length, 1);
assert.equal(docs[0].propA, 'Hi');
done();
})
});
});

it('merges the first pipeline stages if applicable', function(done) {
var aggregate = ImpressionEvent.aggregate([
{$match: {name: 'Test Event'}}
Expand Down

0 comments on commit 7e4077d

Please sign in to comment.