mirror of
https://github.com/strapi/strapi.git
synced 2025-12-17 10:14:19 +00:00
Merge branch 'master' into fix/enumeration
This commit is contained in:
commit
cccf256bf7
@ -8,6 +8,10 @@ const utils = require('./utils');
|
|||||||
const relations = require('./relations');
|
const relations = require('./relations');
|
||||||
const { findComponentByGlobalId } = require('./utils/helpers');
|
const { findComponentByGlobalId } = require('./utils/helpers');
|
||||||
|
|
||||||
|
const isPolymorphicAssoc = assoc => {
|
||||||
|
return assoc.nature.toLowerCase().indexOf('morph') !== -1;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = ({ models, target, plugin = false }, ctx) => {
|
module.exports = ({ models, target, plugin = false }, ctx) => {
|
||||||
const { instance } = ctx;
|
const { instance } = ctx;
|
||||||
|
|
||||||
@ -117,7 +121,7 @@ module.exports = ({ models, target, plugin = false }, ctx) => {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
const morphAssociations = definition.associations.filter(
|
const morphAssociations = definition.associations.filter(
|
||||||
association => association.nature.toLowerCase().indexOf('morph') !== -1
|
isPolymorphicAssoc
|
||||||
);
|
);
|
||||||
|
|
||||||
const populateFn = createOnFetchPopulateFn({
|
const populateFn = createOnFetchPopulateFn({
|
||||||
@ -366,6 +370,7 @@ const createOnFetchPopulateFn = ({
|
|||||||
|
|
||||||
if (definition.modelType === 'component') {
|
if (definition.modelType === 'component') {
|
||||||
definition.associations
|
definition.associations
|
||||||
|
.filter(assoc => !isPolymorphicAssoc(assoc))
|
||||||
.filter(ast => ast.autoPopulate !== false)
|
.filter(ast => ast.autoPopulate !== false)
|
||||||
.forEach(ast => {
|
.forEach(ast => {
|
||||||
this.populate({ path: ast.alias });
|
this.populate({ path: ast.alias });
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user