Fixes #13582: PK column in yii\db\pgsql\resetSequence() was not quoted properly

This commit is contained in:
Bob Olde Hampsink
2017-02-19 15:35:59 +01:00
committed by Alexander Makarov
parent 323568c2e9
commit aeb6231d92
2 changed files with 3 additions and 2 deletions

View File

@ -14,6 +14,7 @@ Yii Framework 2 Change Log
- Bug #11404: `yii\base\Model::loadMultiple()` returns true even if `yii\base\Model::load()` returns false (zvook) - Bug #11404: `yii\base\Model::loadMultiple()` returns true even if `yii\base\Model::load()` returns false (zvook)
- Bug #13513: Fixed RBAC migration to work correctly on Oracle DBMS (silverfire) - Bug #13513: Fixed RBAC migration to work correctly on Oracle DBMS (silverfire)
- Enh #13550: Refactored unset call order in `yii\di\ServiceLocator::set()` (Lanrik) - Enh #13550: Refactored unset call order in `yii\di\ServiceLocator::set()` (Lanrik)
- Bug #13582: PK column in `yii\db\pgsql\resetSequence()` was not quoted properly (boboldehampsink)
- Bug #13592: Fixes Oracles `yii\db\oci\Schema::setTransactionIsolationLevel()` (sergeymakinen) - Bug #13592: Fixes Oracles `yii\db\oci\Schema::setTransactionIsolationLevel()` (sergeymakinen)
- Bug #13594: Fixes insufficient quoting in `yii\db\QueryBuilder::prepareInsertSelectSubQuery()` (sergeymakinen) - Bug #13594: Fixes insufficient quoting in `yii\db\QueryBuilder::prepareInsertSelectSubQuery()` (sergeymakinen)
- Enh #13576: Added support of `srcset` to `yii\helpers\Html::img()` (Kolyunya) - Enh #13576: Added support of `srcset` to `yii\helpers\Html::img()` (Kolyunya)

View File

@ -164,8 +164,8 @@ class QueryBuilder extends \yii\db\QueryBuilder
$sequence = $this->db->quoteTableName($table->sequenceName); $sequence = $this->db->quoteTableName($table->sequenceName);
$tableName = $this->db->quoteTableName($tableName); $tableName = $this->db->quoteTableName($tableName);
if ($value === null) { if ($value === null) {
$key = reset($table->primaryKey); $key = $this->db->quoteColumnName(reset($table->primaryKey));
$value = "(SELECT COALESCE(MAX(\"{$key}\"),0) FROM {$tableName})+1"; $value = "(SELECT COALESCE(MAX({$key}),0) FROM {$tableName})+1";
} else { } else {
$value = (int) $value; $value = (int) $value;
} }