refs #11122: Fixed can not use orderBy with aggregate functions (#12772)

* refs #11122: Fixed can not use `orderBy` with aggregate functions like `count`, `max` etc.

* Update QueryTest.php
This commit is contained in:
Pavel Chaplygin
2016-12-18 16:28:34 +07:00
committed by Dmitry Naumenko
parent a710345ea7
commit 25e6eb04a5
3 changed files with 12 additions and 1 deletions

View File

@ -421,7 +421,13 @@ class Query extends Component implements QueryInterface
$this->limit = $limit;
$this->offset = $offset;
if (empty($this->groupBy) && empty($this->having) && empty($this->union) && !$this->distinct) {
if (
!$this->distinct
&& empty($this->groupBy)
&& empty($this->having)
&& empty($this->union)
&& empty($this->orderBy)
) {
return $command->queryScalar();
} else {
return (new Query)->select([$selectExpression])