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
On the surface it works well, my view showing number of programs of each channel as expected.
However, when I typed in search box, like 'sport', Datatables.js complains that there is something wrong when it fetched data and did not render the table.
I dug into laravel.log to see what exactly happened. It turns out that bllim constructed the SQL incorrectly like so:
selectcount(*)
as aggregate from
(select'1'as row from`channels`left join`programs`on`programs`.`channel_id`=`channels`.`id`where`channels`.`deleted_at` is nullandLOWER(channels.id) LIKE %sport% orLOWER(channels.name_en) LIKE %sport% orLOWER(channels.name) LIKE %sport% orLOWER(COUNT(programs.id)) LIKE %sport%
group by`channels`.`id`)
AS count_row_table
where all those LIKE operators did not compare with strings, let alone it even generates something is syntax error, like LOWER(COUNT(programs.id)) LIKE %sport%.
Next I did some searching in program list view. The underlying program query builder is simpler without groupBy():
This time Datatables.js rendered view correctly.
Again, I checked laravel.log and I found no syntax error in the SQL constructed:
selectcount(*) as aggregate
from (select'1'as row from`programs`left join`channels`on`channels`.`id`=`programs`.`channel_id`where`programs`.`deleted_at` is nulland (LOWER(programs.id) LIKE'%ebert%'orLOWER(programs.name) LIKE'%ebert%'orLOWER(programs.name_en) LIKE'%ebert%'orLOWER(channels.name) LIKE'%ebert%'orLOWER(programs.start_date) LIKE'%ebert%'orLOWER(programs.end_date) LIKE'%ebert%'))
AS count_row_table
where term ebert was properly quoted.
The text was updated successfully, but these errors were encountered:
The package may have a bug when it constructs SQL that uses group by.
I have two models: Channel and Program, and a Channel could have many Programs.
Use case: Display how many programs each channel has in channel list.
A very common way to achieve this is to use count() and group by in SQL.
So in php I define a query builder as follows:
And then let the package to generate JSON for us:
On the surface it works well, my view showing number of programs of each channel as expected.
However, when I typed in search box, like 'sport', Datatables.js complains that there is something wrong when it fetched data and did not render the table.
I dug into laravel.log to see what exactly happened. It turns out that bllim constructed the SQL incorrectly like so:
where all those LIKE operators did not compare with strings, let alone it even generates something is syntax error, like LOWER(COUNT(programs.id)) LIKE %sport%.
Next I did some searching in program list view. The underlying program query builder is simpler without groupBy():
This time Datatables.js rendered view correctly.
Again, I checked laravel.log and I found no syntax error in the SQL constructed:
where term ebert was properly quoted.
The text was updated successfully, but these errors were encountered: