Skip to content

Commit

Permalink
fix(populate): dedupe model names with embedded discriminators
Browse files Browse the repository at this point in the history
Re: #5983
  • Loading branch information
vkarpov15 committed Jan 26, 2018
1 parent b4b59c4 commit b510cb9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3573,7 +3573,12 @@ function getModelsMapForPopulate(model, docs, options) {
if (!_modelNames) {
continue;
}
modelNames = (modelNames || []).concat(_modelNames);
modelNames = (modelNames || []);
for (var k = 0; k < _modelNames.length; ++k) {
if (modelNames.indexOf(_modelNames[k]) === -1) {
modelNames.push(_modelNames[k]);
}
}
}
} else {
modelNames = _getModelNames(doc, schema);
Expand Down Expand Up @@ -3674,6 +3679,7 @@ function getModelsMapForPopulate(model, docs, options) {

function _getModelNames(doc, schema) {
var modelNames;
var discriminatorKey;

if (schema && schema.caster) {
schema = schema.caster;
Expand Down

0 comments on commit b510cb9

Please sign in to comment.