Fix from e719ff5 moved to yii\sphinx\Query

This commit is contained in:
Paul Klimov
2014-12-23 18:39:52 +02:00
parent e719ff5854
commit 5ad6ba5c9e
4 changed files with 31 additions and 4 deletions

View File

@ -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

View File

@ -366,6 +366,34 @@ class Query extends \yii\db\Query
->queryColumn(); ->queryColumn();
} }
/**
* @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.

View File

@ -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)

View File

@ -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
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();