Skip to content

Commit

Permalink
test(query): repro #10029
Browse files Browse the repository at this point in the history
  • Loading branch information
vkarpov15 committed Mar 22, 2021
1 parent 4b0052e commit 7d19c9f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/query.test.js
Expand Up @@ -3757,4 +3757,23 @@ describe('Query', function() {
assert.equal(called.length, 1);
});
});

it('applies schema-level `select` on arrays (gh-10029)', function() {
const testSchema = new mongoose.Schema({
doesntpopulate: {
type: [mongoose.Schema.Types.ObjectId],
select: false
},
populatescorrectly: [{
type: mongoose.Schema.Types.ObjectId,
select: false
}]
});
const Test = db.model('Test', testSchema);

const q = Test.find();
q._applyPaths();

assert.deepEqual(q._fields, { doesntpopulate: 0, populatescorrectly: 0 });
});
});

0 comments on commit 7d19c9f

Please sign in to comment.