Skip to content

Commit a8c9280

Browse files
authored
Merge pull request #2612 from sebastienheyd/9.0
Fix the regression when using a having condition in a query. Fix #1928
2 parents 4271f77 + 4f80389 commit a8c9280

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/QueryDataTable.php

+11-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,17 @@ protected function filteredCount()
210210
*/
211211
public function count()
212212
{
213-
return $this->prepareCountQuery()->count();
213+
$builder = $this->prepareCountQuery();
214+
215+
if (empty($builder->havings)) {
216+
return $builder->count();
217+
}
218+
219+
$table = $this->connection->raw('('.$builder->toSql().') count_row_table');
220+
221+
return $this->connection->table($table)
222+
->setBindings($builder->getBindings())
223+
->count();
214224
}
215225

216226
/**

0 commit comments

Comments
 (0)