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

[8.x] Fix Self-Relation issue in withAggregate method #35392

Merged
merged 1 commit into from
Nov 27, 2020

Conversation

khalilst
Copy link
Contributor

@khalilst khalilst commented Nov 27, 2020

This PR is created in following of the PR #35389 .

It modifies the getRelationCountHash to provide a way to predict the hash.
It prevents increasing $selfJoinCount, if called like this:

$relation->getRelationCountHash(true)

@khalilst khalilst force-pushed the self-related-withAggregate branch 3 times, most recently from 8c62084 to f8bd393 Compare November 27, 2020 17:57
@taylorotwell
Copy link
Member

What does $fixed mean? Can that be given an actually descriptive variable name?

@khalilst
Copy link
Contributor Author

khalilst commented Nov 27, 2020

@taylorotwell OK. I'm gonna change the $fixed into $lockCount.

@khalilst khalilst force-pushed the self-related-withAggregate branch from f8bd393 to 07397ce Compare November 27, 2020 19:15
@bjuppa
Copy link

bjuppa commented Nov 27, 2020

@khalilst perhaps you can just copy the failing test from #35389 into this PR?

@taylorotwell
Copy link
Member

No tests?

@taylorotwell
Copy link
Member

Added test.

@taylorotwell taylorotwell merged commit 07397ce into laravel:8.x Nov 27, 2020
@khalilst
Copy link
Contributor Author

khalilst commented Nov 27, 2020

@bjuppa as I have commented in your PR, I was waiting for permission to use your test.
Btw, it was added by @taylorotwell .
Thank you all.

@dbakan
Copy link
Contributor

dbakan commented Nov 27, 2020

Could this be a breaking change? Changing the signature of getRelationCountHash? I‘m not sure, just asking.

@khalilst
Copy link
Contributor Author

@dbakan No. It's not. Because of the default value of $lockCount = false the previous signature supported.
Also, the instance of the $relation have been checked in withAggregate for special case.

@GrahamCampbell
Copy link
Member

The breaking change would be for people extending the class and overriding the method.

@dbakan
Copy link
Contributor

dbakan commented Nov 27, 2020

@GrahamCampbell That's what I thought.

Another idea might have been to add a new method getCurrentRelationCountHash.

@dbakan
Copy link
Contributor

dbakan commented Nov 27, 2020

@khalilst Just to clarify what I meant: https://3v4l.org/KIleN
But maybe this not a bigger problem. Nice work anyway, thanks!

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.

5 participants