yiisoft / db

Yii Database Library
https://www.yiiframework.com/
BSD 3-Clause "New" or "Revised" License
134 stars 35 forks source link

Allow scalars `int|float|bool` in `Query::select()` #763

Closed Tigrov closed 7 months ago

Tigrov commented 1 year ago

For some cases a query like SELECT 1 FROM ... required. If allow scalars int|float|bool for columns in Query::select() method, the result could be $query->select(1) => SELECT 1 FROM ... or with alias $query->select(['a' => 1]) => SELECT 1 AS "a" FROM ...

Currently using Query instance it could be done like $query->select(new Expression('1')) or $query->select('(1)')

vjik commented 1 year ago

Suggestion looks good.