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

FIX eagerLoad crash with nonterminal hasOne relation #11483

Open
wants to merge 1 commit into
base: 5.3
Choose a base branch
from

Conversation

MasonD
Copy link
Contributor

@MasonD MasonD commented Nov 29, 2024

Addresses #11470

@MasonD
Copy link
Contributor Author

MasonD commented Nov 29, 2024

Looks like the failing tests are because the number of queries is no longer as previously expected. I'd appreciate input on how what I've done here has caused extra queries.

@GuySartorelli
Copy link
Member

Looks like the failing tests are because the number of queries is no longer as previously expected. I'd appreciate input on how what I've done here has caused extra queries.

My guess, having looked briefly at the code changes but not at the tests, is that the tests were actually not correct, and chains with has_one weren't actually checking anything after the has_one portion.
I don't have time to dive into the tests right now to validate that - can you please try to check whether the new results are correct or not?

@MasonD
Copy link
Contributor Author

MasonD commented Dec 2, 2024

After investigation, the tests indeed did their job and caught a bug in my code, now fixed.

@MasonD
Copy link
Contributor Author

MasonD commented Dec 12, 2024

@GuySartorelli I did resolve the failing tests, in case you missed it. The tests were correct and I was missing out on some eager fetching because of a bug.

@GuySartorelli
Copy link
Member

Thanks yup. I saw that just haven't had a chance to come back to this yet.

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good and seems to work as expected, thanks for taking the time to do this.

Couple of things:

  1. Can you please add some unit tests? One to check that this works as expected for HasOne.HasMany (i.e. the intended use case) and one to check that the exception is thrown for PolymorphicHasOne.HasMany?
  2. Can you please retarget this to the 5.3 branch? That way the patch can be released immediately rather than waiting for the April minor release.
    You may need to reset your commits after retargeting the PR.

src/ORM/DataList.php Outdated Show resolved Hide resolved
@MasonD MasonD changed the base branch from 5 to 5.3 December 13, 2024 05:11
@MasonD MasonD force-pushed the pull/5/eagerLoad-hasOne-error branch from 1239859 to 18392e7 Compare December 13, 2024 05:15
@MasonD MasonD force-pushed the pull/5/eagerLoad-hasOne-error branch from 18392e7 to 25ed64f Compare December 13, 2024 05:21
@MasonD
Copy link
Contributor Author

MasonD commented Dec 13, 2024

@GuySartorelli all done!

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

Successfully merging this pull request may close these issues.

2 participants