You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and two columns in the datatable with these relation (country_from.name, country_to.name). I need to use filtering by both columns at the same time and I got a problem: when the second relation is applied the join is omitted since it's already joined and same table used in WHERE condition:
It makes since until you need to join the same table. I figured out a way to make it work like it supposed to in my case, but Im not sure it's PR worth hack and it's not thoroughly tested :) Here's what I did.
Generate an alias for the table if it's already joined and return it with performJoin method (sorry, not the cleanest code):
@affaron thank you for investigating. This is currently a package limitation and doesn't work yet with a self-join relationship. If you can add a support for it, please do not hesitate to submit a PR.
Hi!
Recently I discovered an issue when using multiple column search with different relation using the same table. Here's what I mean.
I have a model with relations:
and two columns in the datatable with these relation (country_from.name, country_to.name). I need to use filtering by both columns at the same time and I got a problem: when the second relation is applied the join is omitted since it's already joined and same table used in WHERE condition:
This happens because of this code:
laravel-datatables/src/EloquentDataTable.php
Lines 251 to 253 in 9e96d1f
It makes since until you need to join the same table. I figured out a way to make it work like it supposed to in my case, but Im not sure it's PR worth hack and it's not thoroughly tested :) Here's what I did.
Generate an alias for the table if it's already joined and return it with performJoin method (sorry, not the cleanest code):
and use this alias in the end of
joinEagerLoadedColumn()
method:after that the lib can generate accurate query:
Maybe I'm missing something and there's a native or more simple way to do that without code changes? Please let me know, thanks
The text was updated successfully, but these errors were encountered: