After updating from 2.0.13 to 2.0.14 i have noticed some strange behavior of Query::select().
If you reassign select fields, duplicates will be removed like in example below:
$query = (new yii\db\Query())
->select('id')
->from('place')
;
$query->select(['id', 'brand_id']);
return $query->one();
[
'id' => 1,
'brand_id' => 1,
]
[
'brand_id' => 1,
]
Notice: if define id inside select with alias in first __or__ second definition (i.e ['id_alias' => 'id']), it will be ok and id will be selected.
It seems that such behavior occurs because of Query::getUniqueColumns(), added in 2.0.14.
Maybe related with: #15674
| Q | A
| ---------------- | ---
| Yii version | 2.0.14
| PHP version | 7.1.14
| DB | mysql 5.7
Fixed, thank you
with fix isn't worked on select's like
->select([
'prefix' => 'LEFT(name, 7)',
'prefix_key' => 'LEFT(name, 7)',
])
because array_unique filtered out without compare array keys
Could you open a separate issue, please?
Thank you
Most helpful comment
with fix isn't worked on select's like
->select([
'prefix' => 'LEFT(name, 7)',
'prefix_key' => 'LEFT(name, 7)',
])
because array_unique filtered out without compare array keys