-
Notifications
You must be signed in to change notification settings - Fork 49
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
Problems loading data for many-to-many relation #119
Comments
This first column is supposed to be used to match the related models appropriately. Unfortunately, It seems something isn't quite right with the generated code. I'll find some time to look into this in the coming weeks. |
Thank you. If it helps, here's the debug SQL for the first code (which runs but doesn't populate the jets data): SELECT
"pilots"."id" AS "id", "pilots"."name" AS "name"
FROM "pilots" AS "pilots"
SELECT
"pilots_jets"."pilot_id" AS "related_pilots.ID"
FROM "jets" AS "jets"
INNER JOIN "pilots_jets" ON ("jets"."id" = "pilots_jets"."jet_id")
WHERE (("pilots_jets"."pilot_id") IN (($1), ($2), ($3)))
0: 1
1: 2
2: 3 It's not even trying to query columns from the |
This issue should be fixed by #139, try it out and let me know. I assume you were just trying workarounds, but please note that
|
Given the following schema and code:
The resulting data (as JSON with back-referencing disabled and struct tag options changed) looks like:
Note the zero-value
id
andname
attributes on theJets
elements.Using additional
ThenLoad
orPreload
doesn't work:Using
bob.Debug
for the latter yields this SQL:Iterating over the returned pilots and calling
LoadPilotsJets()
for each one is a workaround but definitely less convenient in the code. Another "workaround" is having an additional column in the associative table, in which case the generated code doesn't have a pass-through and the following code works:Note that data is populated for the
notes
attribute (where it exists in the DB) as well as theJet
id
andname
attributes.The text was updated successfully, but these errors were encountered: