Skip to content

Commit

Permalink
Merge pull request #2612 from sebastienheyd/9.0
Browse files Browse the repository at this point in the history
Fix the regression when using a having condition in a query. 
Fix #1928
  • Loading branch information
yajra authored Apr 14, 2021
2 parents 4271f77 + 4f80389 commit a8c9280
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/QueryDataTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,17 @@ protected function filteredCount()
*/
public function count()
{
return $this->prepareCountQuery()->count();
$builder = $this->prepareCountQuery();

if (empty($builder->havings)) {
return $builder->count();
}

$table = $this->connection->raw('('.$builder->toSql().') count_row_table');

return $this->connection->table($table)
->setBindings($builder->getBindings())
->count();
}

/**
Expand Down

0 comments on commit a8c9280

Please sign in to comment.