Skip to content

Commit 75f7cb9

Browse files
author
Lisa Fehr
committed
Update Datatables.php
"select distinct '1' as row_count" always made count = 1
1 parent 7184562 commit 75f7cb9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/yajra/Datatables/Datatables.php

Lines changed: 2 additions & 2 deletions
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 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 (! preg_match('/(UNION|DISTINCT)/i', strtoupper($myQuery->toSql()))) {
333333
$myQuery->select($this->connection->raw("'1' as row_count"));
334334
}
335335

0 commit comments

Comments
 (0)