-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Using expressions in pivot queries #50787
Comments
@tpetry is this something we need to fix as well? |
Yeah, special handling in the core is required to unwrap expressions in this case. But due to personal stuff, I cant work on this currently. |
No worries at all @tpetry. Will leave this one open for anyone to pick up. |
Thank you for reporting this issue! As Laravel is an open source project, we rely on the community to help us diagnose and fix issues as it is not possible to research and fix every issue reported to us via GitHub. If possible, please make a pull request fixing the issue you have described, along with corresponding tests. All pull requests are promptly reviewed by the Laravel team. Thank you! |
Thanks @Jigsaw5279 for reporting that, I have fixed that in #50849 |
Laravel Version
10.48.3
PHP Version
8.3.3
Database Driver & Version
mysqlnd 8.3.3
Description
This issue is similar to #49894, but for querying pivot relations with raw expressions.
In Laravel 9 it was possible to do this:
which would produce a where statement like
CONCAT(some_field, '_', other_field) not in (?, ?)
which is to be expected.With the changes of enforcing manual casting of the expression to its raw value, I can no longer get
wherePivotNotIn
to produce the expected output.now produces the following where clause
which is correctly identified by mysql as an unknown field.
Following the callgraph, I can get rid of the database and table prefix, by prefixing the concatenated fields myself (see https://github.com/laravel/framework/blob/10.x/src/Illuminate/Database/Eloquent/Relations/BelongsToMany.php#L1527 ).
But then somehwhere in the wrap function it gets mangled again:
I'm not confident enough to fiddle around in the guts of eloquent to create a PR for this, so any help would be greatly appreciated
Steps To Reproduce
morphToMany
relationshipThe text was updated successfully, but these errors were encountered: