Commit 271dccdc by Qiang Xue

Fixes #2931.

parent cca97f37
...@@ -102,7 +102,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -102,7 +102,7 @@ class ActiveRecord extends BaseActiveRecord
public function loadDefaultValues($skipIfSet = true) public function loadDefaultValues($skipIfSet = true)
{ {
foreach ($this->getTableSchema()->columns as $column) { foreach ($this->getTableSchema()->columns as $column) {
if ($column->defaultValue && !($skipIfSet && $this->{$column->name} !== null)) { if ($column->defaultValue !== null && (!$skipIfSet || $this->{$column->name} === null)) {
$this->{$column->name} = $column->defaultValue; $this->{$column->name} = $column->defaultValue;
} }
} }
...@@ -117,7 +117,7 @@ class ActiveRecord extends BaseActiveRecord ...@@ -117,7 +117,7 @@ class ActiveRecord extends BaseActiveRecord
*/ */
public static function getDb() public static function getDb()
{ {
return \Yii::$app->getDb(); return Yii::$app->getDb();
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment