mirror of
https://github.com/yiisoft/yii2.git
synced 2026-03-24 07:57:10 +01:00
Fix #18499: When using yii\db\Query::all() and yii\db\Query::$indexBy, the yii\db\Query::$indexBy is auto inserted into yii\db\Query::$select - the same as in yii\db\Query::column()
Co-authored-by: Bizley <pawel@positive.codes> Co-authored-by: Alexander Makarov <sam@rmcreative.ru>
This commit is contained in:
@@ -245,7 +245,16 @@ class Query extends Component implements QueryInterface, ExpressionInterface
|
||||
if ($this->emulateExecution) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (is_string($this->indexBy) && $this->indexBy && is_array($this->select) && !in_array($this->indexBy, $this->select)) {
|
||||
if (strpos($this->indexBy, '.') === false && count($tables = $this->getTablesUsedInFrom()) > 0) {
|
||||
$this->select[] = key($tables) . '.' . $this->indexBy;
|
||||
} else {
|
||||
$this->select[] = $this->indexBy;
|
||||
}
|
||||
}
|
||||
$rows = $this->createCommand($db)->queryAll();
|
||||
|
||||
return $this->populate($rows);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user