Skip to content

Commit a498c84

Browse files
committed
Merge pull request yajra#243 from lisa-fehr/patch-3
count method needs to check for distinct as well as union
2 parents 35116ed + 1cecbb5 commit a498c84

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/yajra/Datatables/Datatables.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,9 @@ private function count()
327327
{
328328
$query = $this->query;
329329

330-
// if its a normal query ( no union ) replace the select with static text to improve performance
330+
// if its a normal query ( no union, having or distinct ) replace the select with static text to improve performance
331331
$myQuery = clone $query;
332-
if (! preg_match('/UNION/i', strtoupper($myQuery->toSql()))) {
332+
if ( ! Str::contains(Str::lower($myQuery->toSql()), ['union', 'having', 'distinct'])) {
333333
$myQuery->select($this->connection->raw("'1' as row_count"));
334334
}
335335

0 commit comments

Comments
 (0)