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

EagerPreload only loading last association when using long association paths #626

Open
reggieriser opened this issue Feb 11, 2021 · 0 comments
Labels
f: associations the associations feature in pop s: triage Some tests need to be run to confirm the issue

Comments

@reggieriser
Copy link
Contributor

Description

EagerPreload does not seem to be loading all associations in 3+ level association paths where the first 2 levels are the same. Here's an example using the test model structs in pop_test.go:

writers := []Writer{}
tx.EagerPreload("Book.Taxi.Driver", "Book.Taxi.Address").All(&writers)

In this case, only the Book.Taxi.Address struct is populated. The Book.Taxi.Driver struct will have zero values (or be nil if a pointer field).

If I change the above to an Eager call, things seem to work fine.

If I shorten the paths to something smaller like below (but still use EagerPreload), it works fine as well:

writers := []Writer{}
tx.EagerPreload("Book.Taxi", "Book.User").All(&writers)

Steps to Reproduce the Problem

I made a test case that demonstrates the issue in a branch on my fork: master...reggieriser:preload-third-level-test

Expected Behavior

I would expect identical Eager and EagerPreload calls to be interchangeable with no difference in the resulting structs' values.

Actual Behavior

An association is not being loaded with EagerPreload

Info

Mac OS 10.15.7, Pop 5.3.3, not using Pop through Buffalo

@larrymjordan larrymjordan added the f: associations the associations feature in pop label May 5, 2021
@sio4 sio4 added the s: triage Some tests need to be run to confirm the issue label Sep 20, 2022
@sio4 sio4 added this to the v6.1.0 milestone Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: associations the associations feature in pop s: triage Some tests need to be run to confirm the issue
Projects
None yet
Development

No branches or pull requests

3 participants