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

eager loading not working with nested populate using find query #5057

Closed
5 tasks done
dimitriSaplatkin opened this issue Dec 28, 2023 · 4 comments
Closed
5 tasks done

Comments

@dimitriSaplatkin
Copy link

Describe the bug

When I call a find query with a populate then the eager loading is not working for the nested populated entity.
Let's say we have the following query:

const authors = await orm.em.find(
      Author,
      { firstName: "Jon" },
      { populate: ["books", "books.genre"] },
    );

On the Genre entity there is another ManyToOne property with the option eager: true.

I would now expect this property is also populated. This case was working for us on mirko-orm v5.

You can see the full reproduciton in the provided github repo

Reproduction

https://github.com/dimitriSaplatkin/reproduction

What driver are you using?

@mikro-orm/postgresql

MikroORM version

6

Node.js version

20

Operating system

Ubuntu 23

Validations

@B4nan
Copy link
Member

B4nan commented Dec 29, 2023

This is actually caused by you passing the books hint twice, if you omit the first one it works fine:

const authors = await orm.em.find(
  Author,
  { firstName: 'Jon' },
  { populate: ['books.genre'] },
);

@B4nan B4nan closed this as completed in 2020296 Dec 29, 2023
@dimitriSaplatkin
Copy link
Author

Hmm okay. But it feels a bit like inconsistent behavior because it works for a findOne query in my example to populate

{ populate: ["books", "books.genre"] },

So I would expect that it also should not work for a fineOne query

@B4nan
Copy link
Member

B4nan commented Dec 30, 2023

I closed the issue with a fix, I guess you missed that? Otherwise I'd rather expect "thank you" instead of "hmm okay" :D

B4nan added a commit that referenced this issue Dec 30, 2023
@dimitriSaplatkin
Copy link
Author

Sorry, my bad. I didn't saw the fix. Thanks for fixing and Happy New Year 🎉.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants