From fb945866c76d56b693c7cb76d8d144e52e2f8d84 Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 20 Nov 2013 16:00:10 -0500 Subject: [PATCH] Fixes #1255: typecast empty string to null for non-string DB columns. --- framework/yii/db/ColumnSchema.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/framework/yii/db/ColumnSchema.php b/framework/yii/db/ColumnSchema.php index cd2d9fa..3e7f6cf 100644 --- a/framework/yii/db/ColumnSchema.php +++ b/framework/yii/db/ColumnSchema.php @@ -87,12 +87,12 @@ class ColumnSchema extends Object */ public function typecast($value) { + if ($value === '' && $this->type !== Schema::TYPE_TEXT && $this->type !== Schema::TYPE_STRING && $this->type !== Schema::TYPE_BINARY) { + return null; + } if ($value === null || gettype($value) === $this->phpType || $value instanceof Expression) { return $value; } - if ($value === '' && $this->type !== Schema::TYPE_TEXT && $this->type !== Schema::TYPE_STRING) { - return null; - } switch ($this->phpType) { case 'string': return (string)$value;