livewire-datatables
livewire-datatables copied to clipboard
NumberColumn::raw using filter ( filterable() ) gives error when use the operation SUM() with GroupBy() (want to use WHERE instead HAVING)
The Query():
return Petition::query()
->groupBy('person_id')
->where('type_id','2');
I have a column like this:
NumberColumn::raw('SUM(cant) AS cant_total')
->filterable()
->enableSummary()
->label('Total Cant.'),
If I try to use the filter I have the error:
SQLSTATE[HY000]: General error: 1111 Invalid use of group function
where
(
`type_id` = 2
)
and (SUM(cant) >= 1000)
this fails since the raw column is working in conjunction with the GroupBy() of my Query() so the condition should not go in WHERE, it should go with HAVING.
I dont know if I can fix this with something (I am going to try) but it will be great if livewire-datatables will apply this automatically.