Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inline relations not being selected automatically when populated #14695

Merged
merged 1 commit into from
Oct 20, 2022

Conversation

Convly
Copy link
Member

@Convly Convly commented Oct 20, 2022

What does it do?

When dealing with relations not using join tables, it appears that they're not automatically selected when populated.

Why is it needed?

Allow populating inline relations without having to select all the fields.

How to test it?

  • Use a content type having creators fields (createdBy, updatedBy)
  • Create some entities from the content manager (so that createdBy and updatedBy are filled)
  • Make a query to this content type
await strapi.entityService.findMany("<uid>", {
  fields: ["id"],
  populate: {
    createdBy: {
      fields: ["id"]
    }
  }
});
  • You should have both the id of your entity and a createdBy: { id: X } property.

@Convly Convly added source: core:database Source is core/database package pr: fix This PR is fixing a bug labels Oct 20, 2022
@codecov
Copy link

codecov bot commented Oct 20, 2022

Codecov Report

Base: 58.76% // Head: 58.76% // Decreases project coverage by -0.00% ⚠️

Coverage data is based on head (b4f4b49) compared to base (65feb97).
Patch coverage: 0.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #14695      +/-   ##
==========================================
- Coverage   58.76%   58.76%   -0.01%     
==========================================
  Files        1322     1322              
  Lines       32040    32042       +2     
  Branches     5981     5987       +6     
==========================================
  Hits        18829    18829              
- Misses      11350    11351       +1     
- Partials     1861     1862       +1     
Flag Coverage Δ
front 62.47% <ø> (ø)
unit 50.20% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ckages/core/database/lib/query/helpers/populate.js 2.95% <0.00%> (-0.03%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@alexandrebodin alexandrebodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Convly Convly added this to the 4.4.6 milestone Oct 20, 2022
@Convly Convly merged commit 2a4d0ca into main Oct 20, 2022
@Convly Convly deleted the fix/process-populate-join-column-missing-select branch October 20, 2022 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: fix This PR is fixing a bug source: core:database Source is core/database package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants