Merge pull request #14032 from strapi/fix/populate-dz

Ignore if populating a scalar attribute
This commit is contained in:
Pierre Noël 2022-08-11 15:38:41 +02:00 committed by GitHub
commit d49d687e72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -32,6 +32,10 @@ const compo2 = {
name: {
type: 'string',
},
category: {
// same field name as in compo1 but different type
type: 'string',
},
category_diff: {
type: 'relation',
relation: 'oneToOne',
@ -136,7 +140,7 @@ describe('CM API - Populate dz', () => {
},
{
__component: 'default.compo-b',
items: { id: 2, name: 'BBBB', category_diff: data.categories[0].id },
items: { id: 2, name: 'BBBB', category_diff: data.categories[0].id, category: 'smthg' },
},
],
},
@ -162,6 +166,7 @@ describe('CM API - Populate dz', () => {
__component: 'default.compo-b',
items: {
name: 'BBBB',
category: 'smthg',
category_diff: {
name: 'name',
},

View File

@ -80,7 +80,7 @@ const processPopulate = (populate, ctx) => {
}
if (!types.isRelation(attribute.type)) {
throw new Error(`Invalid populate field. Expected a relation, got ${attribute.type}`);
continue;
}
// make sure id is present for future populate queries