Skip to content

Commit

Permalink
fix(document): ensure projection with only $slice isn't treated as in…
Browse files Browse the repository at this point in the history
…clusive for discriminators

Fix #4991
  • Loading branch information
vkarpov15 committed Dec 6, 2017
1 parent 7e4077d commit 7b42c15
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/document.js
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,8 @@ Document.prototype.isSelected = function isSelected(path) {
if (cur === '_id') {
continue;
}
if (this.$__.selected[cur] && this.$__.selected[cur].$meta) {
var projection = this.$__.selected[cur];
if (projection && (projection.$meta || projection.$slice)) {
continue;
}
inclusive = !!this.$__.selected[cur];
Expand Down
4 changes: 2 additions & 2 deletions test/model.discriminator.querying.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1023,13 +1023,13 @@ describe('model', function() {
var Discriminator = Base.discriminator('gh4991_A1', discriminatorSchema);

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

Expand Down

0 comments on commit 7b42c15

Please sign in to comment.