Skip to content

Commit

Permalink
fix(populate): skip checking refPath if the path to populate is und…
Browse files Browse the repository at this point in the history
…efined

Fix #9340
  • Loading branch information
vkarpov15 committed Aug 26, 2020
1 parent 66ba2ec commit 1e76f70
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/helpers/populate/getModelsMapForPopulate.js
Expand Up @@ -282,7 +282,12 @@ module.exports = function getModelsMapForPopulate(model, docs, options) {
originalModel :
modelName[modelSymbol] ? modelName : connection.model(modelName);
} catch (error) {
return error;
// If `ret` is undefined, we'll add an empty entry to modelsMap. We shouldn't
// execute a query, but it is necessary to make sure `justOne` gets handled
// correctly for setting an empty array (see gh-8455)
if (ret !== undefined) {
return error;
}
}

let ids = ret;
Expand Down

0 comments on commit 1e76f70

Please sign in to comment.