Merge branch 'master' into fix/enumeration

This commit is contained in:
Alexandre BODIN 2020-01-06 12:18:37 +01:00 committed by GitHub
commit cccf256bf7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -8,6 +8,10 @@ const utils = require('./utils');
const relations = require('./relations');
const { findComponentByGlobalId } = require('./utils/helpers');
const isPolymorphicAssoc = assoc => {
return assoc.nature.toLowerCase().indexOf('morph') !== -1;
};
module.exports = ({ models, target, plugin = false }, ctx) => {
const { instance } = ctx;
@ -117,7 +121,7 @@ module.exports = ({ models, target, plugin = false }, ctx) => {
*/
const morphAssociations = definition.associations.filter(
association => association.nature.toLowerCase().indexOf('morph') !== -1
isPolymorphicAssoc
);
const populateFn = createOnFetchPopulateFn({
@ -366,6 +370,7 @@ const createOnFetchPopulateFn = ({
if (definition.modelType === 'component') {
definition.associations
.filter(assoc => !isPolymorphicAssoc(assoc))
.filter(ast => ast.autoPopulate !== false)
.forEach(ast => {
this.populate({ path: ast.alias });