From c608caa0e25765e30d6223906e4bbbb7a59b44ca Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Thu, 14 Sep 2017 10:17:40 +0200 Subject: [PATCH] fix datamapper null value for obj --- DataStorage/Database/DataMapperAbstract.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 8fe38be08..8e9dfbc11 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -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 ?? ''));