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

V6. When populating a Many-to-Many relationship that uses STI, the ORM joins on the wrong column of the pivot table #4423

Closed
YanDjin opened this issue Jun 5, 2023 · 3 comments

Comments

@YanDjin
Copy link

YanDjin commented Jun 5, 2023

Describe the bug
On the version 6, when populating a Many-to-Many relation that uses STI (i did not specify a strategy), the ORM joins on the wrong column of the pivot table.
I tried the same with a relation that does not use STI and it does not seem to have the same issue.

To Reproduce
Steps to reproduce the behavior:

  • use an entity that has a Many-to-Many relationship with an entity that uses STI
  • use a find on the entity that owns the relation
  • specify the relation to be populated, without specifying a strategy
  • when loading the relation, the ORM will join on the wrong column

https://github.com/YanDjin/mikro-orm/blob/bug/find-sti-relation/tests/issues/GH4423.test.ts
this link contains the test that replicates the issue.

Expected behavior
To join the populate request on the correct column of the pivot table

Versions

Dependency Version
node 18.16.0
typescript 5.0.4
mikro-orm 6.0.0-dev.82
your-driver postgres/sqlite
@B4nan
Copy link
Member

B4nan commented Jun 10, 2023

This one is a bit more tricky, I guess I will try to do a bigger refactor to get rid of the weird loadFromPivotTable driver method and use em.populate instead.

@YanDjin
Copy link
Author

YanDjin commented Jun 10, 2023

I just happened to add a hotfix PR, if you have the time to check it out :)

@B4nan
Copy link
Member

B4nan commented Jun 10, 2023

I managed to remove the weird parts from QB (together with this problematic qb.autoJoinPivotTable method), still have a few failing tests to deal with, but this new solution does not suffer from the problem you have in the PR.

B4nan added a commit that referenced this issue Jun 10, 2023
B4nan added a commit that referenced this issue Jun 10, 2023
B4nan added a commit that referenced this issue Jun 10, 2023
B4nan added a commit that referenced this issue Jun 10, 2023
@B4nan B4nan closed this as completed Jun 10, 2023
B4nan added a commit that referenced this issue Jun 11, 2023
B4nan added a commit that referenced this issue Sep 10, 2023
B4nan added a commit that referenced this issue Sep 20, 2023
B4nan added a commit that referenced this issue Sep 24, 2023
B4nan added a commit that referenced this issue Sep 30, 2023
B4nan added a commit that referenced this issue Oct 2, 2023
B4nan added a commit that referenced this issue Oct 17, 2023
B4nan added a commit that referenced this issue Oct 21, 2023
B4nan added a commit that referenced this issue Oct 25, 2023
B4nan added a commit that referenced this issue Nov 2, 2023
B4nan added a commit that referenced this issue Nov 5, 2023
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