From a72e781e026c9a92553b810bd102f5cae3827673 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Sat, 28 Mar 2020 17:26:51 +0100 Subject: [PATCH] Don't load default value if default value is not set --- DataStorage/Database/DataMapperAbstract.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DataStorage/Database/DataMapperAbstract.php b/DataStorage/Database/DataMapperAbstract.php index 8d7ff1b43..bec096ed4 100644 --- a/DataStorage/Database/DataMapperAbstract.php +++ b/DataStorage/Database/DataMapperAbstract.php @@ -2076,7 +2076,7 @@ class DataMapperAbstract implements DataMapperInterface if (isset(static::$ownsOne[$def['internal']])) { $default = null; - if ($depth - 1 < 1) { + if ($depth - 1 < 1 && $refProp->isInitialized($obj)) { $default = $refProp->getValue($obj); } @@ -2085,7 +2085,7 @@ class DataMapperAbstract implements DataMapperInterface $refProp->setValue($obj, $value); } elseif (isset(static::$belongsTo[$def['internal']])) { $default = null; - if ($depth - 1 < 1) { + if ($depth - 1 < 1 && $refProp->isInitialized($obj)) { $default = $refProp->getValue($obj); }