Skip to content

Commit 7d19c9f

Browse files
committedMar 22, 2021
test(query): repro #10029
1 parent 4b0052e commit 7d19c9f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
 

‎test/query.test.js

+19
Original file line numberDiff line numberDiff line change
@@ -3757,4 +3757,23 @@ describe('Query', function() {
37573757
assert.equal(called.length, 1);
37583758
});
37593759
});
3760+
3761+
it('applies schema-level `select` on arrays (gh-10029)', function() {
3762+
const testSchema = new mongoose.Schema({
3763+
doesntpopulate: {
3764+
type: [mongoose.Schema.Types.ObjectId],
3765+
select: false
3766+
},
3767+
populatescorrectly: [{
3768+
type: mongoose.Schema.Types.ObjectId,
3769+
select: false
3770+
}]
3771+
});
3772+
const Test = db.model('Test', testSchema);
3773+
3774+
const q = Test.find();
3775+
q._applyPaths();
3776+
3777+
assert.deepEqual(q._fields, { doesntpopulate: 0, populatescorrectly: 0 });
3778+
});
37603779
});

0 commit comments

Comments
 (0)
Please sign in to comment.