-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Populating Nested Field returns the wrong number of associated entities #144
Comments
Hey, @B4nan , this is either some lousy mistake on my part or an important issue to fix - It looks like populating nested fields is making the wrong associations, which might cause severe bugs 🤔 . I appreciate it if you could help me out with this one! 💡 Edit: I noticed that if we manually initialize each user's profile collection, it returns the correct data. The issue is probably related to the EntityManager - I'd guess it's not filtering which grand-children entities belong to each child entity - As you can see, it's basically grouping all of the existing profiles (3 in total) and associating them with each user. |
@B4nan Hey again Martin, sorry for bothering you again with this, but that issue has been blocking a bit of our progress in a project here. Could you give us some insight? Maybe just pointing out where in the MikroORM code we could try to fix that issue. Thank you! |
Can you create repro without nest js? Just a simple script, ideally everything in a single file. |
Alright, I'll work on it, thanks Martin! |
Hey again, @B4nan! Here's the Repro: https://github.com/thiagomini/mikro-orm-repro And here's the test case: https://github.com/thiagomini/mikro-orm-repro/blob/f48a1d83f8ea9d13da0f0e6f54645a3c7533f2d4/src/mikro-orm.test.ts#L32C2-L32C2 So, apparently, the issue might indeed be with the NestJS package because the very same test here is actually passing 😅 - I'll create another version tomorrow using
|
Describe the bug
Company
entity class with its schemaCompany
has manyUser
'sUser
has manyProfile
'sCompany
from the database, populating bothuser
andprofile
The Diagram below illustrates that:
Stack trace
To Reproduce
Steps to reproduce the behavior:
yarn
docker compose up -d
yarn test
Expected behavior
"User2" should have only ONE associated Profile.
Additional Information
💡 Link to the test case
Versions
The text was updated successfully, but these errors were encountered: