public function aggregate($function, $columns = ['*']) { // Postgres doesn't like ORDER BY when there's no GROUP BY clause if (!isset($this->groups)) { $this->reOrderBy(null); } return parent::aggregate($function, $columns); }