-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Allow passing query Expression as column in Many-to-Many relationship #50849
Conversation
Please use the expression functions from the query grammar. These should be isExpression() and getValue(). And please create tests so this issue can‘t be re-introduced anymore. |
e52430b
to
150418a
Compare
Dear @tpetry |
Looks better 👍 |
I'm not so sure this change belongs in the framework core. The use case seems pretty edge case. |
This is also a breaking change for existing packages that extend the framework's relationship classes. |
I believe that is not a BC as I have fixed edge case which was not working properly. Even if third parties used expressions they are not working correctly |
For 10.x we fixed several cases were expressions had not been handled correctly. To be more clear, 10.x added the bc break because my expression could only handle correctly everything i new off. But expressions could have been used at a ton of places - normally not documented. So in my opinion, this is fixing a bug like many times before. |
This change seems to cause an issue when using an belongsToMany relation in combination with "withoutGlobalScopes". In my case the global scopes are not removed. If i revert this change, all works as expected. Would it be possible to change the call from |
@ccharz Please create a new issue with a reproducible example. This bug get easily missed as a simple comment. |
Query builder supports query expressions when Many-to-Many relationships.
I have fixed that by check if passed column to be qualified with explicit table name is query expression, if so I made a return to use it as developer requested, without qualifying. Added support for expression in clauses methods types. Covered by test which is verifying if base relation methods receives expression.
Moreover, PHPUnit test case replaced with Mockery adapter test case, which closes Mockery by themself.
This MR solves #50787