From b05ea3d69e49e19f45844130d7220f1ee05e7c49 Mon Sep 17 00:00:00 2001 From: Klimov Paul Date: Tue, 14 Apr 2015 12:00:22 +0300 Subject: [PATCH] PK typecast at `yii\db\ActiveRecord` restored --- framework/db/ActiveRecord.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/framework/db/ActiveRecord.php b/framework/db/ActiveRecord.php index 0d9eeebfcc..fad58477c4 100644 --- a/framework/db/ActiveRecord.php +++ b/framework/db/ActiveRecord.php @@ -457,8 +457,14 @@ class ActiveRecord extends BaseActiveRecord if (($primaryKeys = static::getDb()->schema->insert($this->tableName(), $values)) === false) { return false; } - $this->setAttributes($primaryKeys, false); - $values = array_merge($values, $primaryKeys); + foreach ($primaryKeys as $name => $value) { + if ($this->getAttribute($name) === null) { + $id = $this->getTableSchema()->columns[$name]->phpTypecast($value); + $this->setAttribute($name, $id); + $values[$name] = $id; + break; + } + } $changedAttributes = array_fill_keys(array_keys($values), null); $this->setOldAttributes($values);