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

Incorrect eager loading on non singular relation #1266

Open
vincekieft opened this issue Apr 9, 2023 · 4 comments
Open

Incorrect eager loading on non singular relation #1266

vincekieft opened this issue Apr 9, 2023 · 4 comments
Labels

Comments

@vincekieft
Copy link

vincekieft commented Apr 9, 2023

Version: SQLBoiler v4.14.1
DB: mysql 8

Scenario:
I have the following data that is looped through when eager loading:
image

This (by sqlboiler generated) code appends relations to non singular entity:
image

But the break on line 1245 causes the second (identical) item of slice to not have set relations. The resulting struct now doesn't have any SetVariationSets set.

What can I do to resolve this?

Another ticket that is still open and faced the exact same issue: #457

@vincekieft
Copy link
Author

When I remove the break from the generated code the relations are set but I can see how the foreign.R.SetVariation keeps getting overwritten to the last local.
Besides that manually changing the generated code ofc is a no go

@stephenafamo
Copy link
Collaborator

I am not sure when I'll be able to take a good look at this.
In the meantime, if you can send in a PR to fix, that will be appreciated.

@vincekieft
Copy link
Author

I cannot send in a PR, I dont know how to fix this. Dont know this codebase

@James-REANNZ
Copy link

I am also running into this problem. In my case I have a M-N-1 relationship chain and the "1"s aren't distributing over the "N"s properly. This seems to be because the code assumes that the set of objects in "N" is unique when doing the eager load, which doesn't hold when "N" is the set of objects in an M-N relationship.

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

No branches or pull requests

3 participants