Browse Source

Fixes #1255: typecast empty string to null for non-string DB columns.

tags/2.0.0-beta
Qiang Xue 11 years ago
parent
commit
fb945866c7
  1. 6
      framework/yii/db/ColumnSchema.php

6
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;

Loading…
Cancel
Save