qm.Load does not work as expected if the foreign key column isn't in qm.Select #893
Unanswered
vladvelici
asked this question in
Q&A
Replies: 1 comment
-
This is just sort of more badness associated with the way eager loading works. I don't have a good answer for you. It's hard to introspect a query struct because it's all unexported madness. So it's hard to auto-detect or auto-correct. Expected behavior? It shouldn't be but that's where we're at with eager loading atm :( |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi! I'm not sure if this is a bug or just something to be careful with, so I'm not opening an issue. I have roughly this schema:
There are many other columns, but irrelevant here. Foreign key set as expected, location.address_id references address.id.
This kind of query won't return any address:
one.R.Address is simply nil. I'm guessing this is because eager loading does a second query using the one.AddressID for the subsequent WHERE IN statement?
The above query works just fine, address fetched as expected.
Is this intended behaviour? Should there be a check to prevent such cases? Either auto-correct and fetch the foreign key column or return an error?
Beta Was this translation helpful? Give feedback.
All reactions