fix datamapper null value for obj

This commit is contained in:
Dennis Eichhorn 2017-09-14 10:17:40 +02:00
parent 3afc442cf0
commit c608caa0e2

View File

@ -1765,7 +1765,10 @@ class DataMapperAbstract implements DataMapperInterface
}
if (in_array(static::$columns[$column]['type'], ['string', 'int', 'float', 'bool'])) {
settype($value, static::$columns[$column]['type']);
if($reflectionProperty->getValue($obj) !== null) {
settype($value, static::$columns[$column]['type']);
}
$reflectionProperty->setValue($obj, $value);
} elseif (static::$columns[$column]['type'] === 'DateTime') {
$reflectionProperty->setValue($obj, new \DateTime($value ?? ''));