Commit 5ad6ba5c by Paul Klimov

Fix from e719ff58 moved to `yii\sphinx\Query`

parent e719ff58
...@@ -4,7 +4,7 @@ Yii Framework 2 sphinx extension Change Log ...@@ -4,7 +4,7 @@ Yii Framework 2 sphinx extension Change Log
2.0.2 under development 2.0.2 under development
----------------------- -----------------------
- no changes in this release. - Bug #6621: Creating sub query at `yii\sphinx\Query::queryScalar()` fixed (klimov-paul)
2.0.1 December 07, 2014 2.0.1 December 07, 2014
......
...@@ -367,6 +367,34 @@ class Query extends \yii\db\Query ...@@ -367,6 +367,34 @@ class Query extends \yii\db\Query
} }
/** /**
* @inheritdoc
*/
protected function queryScalar($selectExpression, $db)
{
$select = $this->select;
$limit = $this->limit;
$offset = $this->offset;
$this->select = [$selectExpression];
$this->limit = null;
$this->offset = null;
$command = $this->createCommand($db);
$this->select = $select;
$this->limit = $limit;
$this->offset = $offset;
if (empty($this->groupBy) && empty($this->union) && !$this->distinct) {
return $command->queryScalar();
} else {
return (new Query)->select([$selectExpression])
->from(['c' => $this])
->createCommand($command->db)
->queryScalar();
}
}
/**
* Creates a new Query object and copies its property values from an existing one. * Creates a new Query object and copies its property values from an existing one.
* The properties being copies are the ones to be used by query builders. * The properties being copies are the ones to be used by query builders.
* @param Query $from the source query object * @param Query $from the source query object
......
...@@ -7,7 +7,6 @@ Yii Framework 2 Change Log ...@@ -7,7 +7,6 @@ Yii Framework 2 Change Log
- Bug #6080: Oracle DB schema did not load column types correctly (wenbin1989) - Bug #6080: Oracle DB schema did not load column types correctly (wenbin1989)
- Bug #6404: advanced application template `Alert` widget was generating duplicate IDs in case of multiple flashes (SDKiller) - Bug #6404: advanced application template `Alert` widget was generating duplicate IDs in case of multiple flashes (SDKiller)
- Bug #6557: Link URLs generated by `yii\widgets\Menu` are not encoded (qiangxue) - Bug #6557: Link URLs generated by `yii\widgets\Menu` are not encoded (qiangxue)
- Bug #6621: `yii\db\Query::queryScalar()` fixed to use `static` when creating subquery (klimov-paul)
- Enh #6247: Logger and error handler are now using slightly less memory (stepanselyuk, samdark) - Enh #6247: Logger and error handler are now using slightly less memory (stepanselyuk, samdark)
- Enh #6434: Added `yii\behaviors\SluggableBehavior::immutable` to support keeping the generated slug unchanged (trntv) - Enh #6434: Added `yii\behaviors\SluggableBehavior::immutable` to support keeping the generated slug unchanged (trntv)
- Enh #6467: `ActiveForm` will scroll to the nearest visible element when the first error input is hidden (newartix) - Enh #6467: `ActiveForm` will scroll to the nearest visible element when the first error input is hidden (newartix)
......
...@@ -354,7 +354,7 @@ class Query extends Component implements QueryInterface ...@@ -354,7 +354,7 @@ class Query extends Component implements QueryInterface
* @param Connection|null $db * @param Connection|null $db
* @return bool|string * @return bool|string
*/ */
private function queryScalar($selectExpression, $db) protected function queryScalar($selectExpression, $db)
{ {
$select = $this->select; $select = $this->select;
$limit = $this->limit; $limit = $this->limit;
...@@ -372,7 +372,7 @@ class Query extends Component implements QueryInterface ...@@ -372,7 +372,7 @@ class Query extends Component implements QueryInterface
if (empty($this->groupBy) && empty($this->union) && !$this->distinct) { if (empty($this->groupBy) && empty($this->union) && !$this->distinct) {
return $command->queryScalar(); return $command->queryScalar();
} else { } else {
return (new static)->select([$selectExpression]) return (new Query)->select([$selectExpression])
->from(['c' => $this]) ->from(['c' => $this])
->createCommand($command->db) ->createCommand($command->db)
->queryScalar(); ->queryScalar();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment