Closed Tarcisiofl closed 5 years ago
Hi,
I am also facing same problem - searching and sorting not working for 'Eager Loading'.
Thanks
I have the same problem. The problem seems like that "deleted_at" timestamp is referring to not-aliased table, while table is aliased.
The error I got:
Exception Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'logistics_providers.deleted_at' in 'where clause' (SQL: select count(*) as aggregate from (select '1' as `row_count` from `orders` left join `logistics_providers` as `logistics_providers_0` on `orders`.`logistics_provider_id` = `logistics_providers_0`.`id` where `logistics_providers`.`deleted_at` is null and LOWER(`logistics_providers_0`.`name`) LIKE %%test%% and `orders`.`deleted_at` is null) count_row_table)
The above query should refer to logistics_providers_0.deleted_at
but generated query refereed to logistics_providers.deleted_at
Problem seems come from this commit: https://github.com/yajra/laravel-datatables/commit/6c7f997e442a35e99435260b61d594484a87d877#diff-d7663255b88a6aed388d85442e3ec2e0
Downgrading to 9.0.1 fixed my issue.
Thanks for reporting. Reverted the support for self join in relation to this.
v9.1.1 released, kindly check again. Thanks!
Hello @yajra, it still not working for me when trying to filter by any rawColumn. Any hint?
Hi,
The "Self Joins" stopped working (#2051 ), the alias was removed. When do you plan to get this working again?
@Morinohtar we need to resolve the issue on soft deletes first as it breaks existing apps. Haven't got the chance to check it further though.
Well, maybe this would work, assuming the PR i did...
Adding this new line:
$deletedAtAs = $deletedAt ? "{$alias}.{$deletedAt}" : $deletedAt;
And then replace the performJoin()
with:
$this->performJoin($tableAs ?? $table, $foreign, $owner ?? $other, $deletedAtAs ?? $deletedAt);
I added this to the fork i used for the PR.
Yes, that may work. But we need to find a way to identify if the relation uses SoftDeletes trait before applying the delete column. The challenged I think of here was that Laravel automatically appends the delete scope for every query thus it does not uses the table alias that we generated.
Ok, i will leave that to you then ;) But the working self joins
are needed.
Awesome job, keep up, and tks :)
Summary of problem or feature request
I'm having issues with search and filters on
company
eager loading relationship. Also, thecompany model
has aMorphTo
relationship where filter or search also didn't work.Could someone point me out why it is not working?
Code snippet of problem
System details