Chumper / Datatable

This is a laravel 4 package for the server and client side of datatables at http://datatables.net/
https://github.com/Chumper/Datatable
388 stars 154 forks source link

My old patches cherry-picked from master branch #351

Open dlnsk opened 9 years ago

dlnsk commented 9 years ago

Can't pass function name through setCallbacks because it encoding as option.

timgws commented 9 years ago

Thanks for this PR, @dlnsk...

dlnsk commented 9 years ago

Next commit (1853d41) fix wrong count when groupBy used in query.

Javier-Rotelli commented 9 years ago

hey @dlnsk your first commit it's doing the same thing that i did here: https://github.com/Chumper/Datatable/pull/348 ?

timgws commented 9 years ago

@dlnsk did you try setting the noGroupByOnCount option on QueryEngine? This should remove the group by before doing the count, which should lead to having the correct table count.

Doing:

        return \DB::table(\DB::raw('('.$originalBuilder->toSql().') as temp_tbl'))
                    ->mergeBindings($originalBuilder->getQuery())
                    ->count();

is not good, because it means a full table scan will need to be done for each search, sort and count, which will be extremely slow (http://dev.mysql.com/doc/refman/5.7/en/subquery-optimization.html)

dlnsk commented 9 years ago

@timgws it isn't the same. When I use groupBy I want know how many groups there are. Not how many items in all groups which noGroupByOnCount gives. I can use setSearchWithAlias() but in my opinion it should be slower than subquery because need to send hundreds or even thousands records through network layer for php's count(). And it gives wrong result for language.infoFiltered ("filtered from MAX total entries") message.

dlnsk commented 9 years ago

@Javier-Rotelli yes ;o) but in little less lines

Javier-Rotelli commented 9 years ago

true :p in this commit e035066 is a test for that functionality. maybe it helps

dlnsk commented 9 years ago

@Javier-Rotelli thanks but it already in main develop branch