Commit fb945866 by Qiang Xue

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

parent c5e8aabe
......@@ -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;
......
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