diff --git a/application/Espo/ORM/Repository/RDBRepository.php b/application/Espo/ORM/Repository/RDBRepository.php index 6b0099b1d5..d5170486cf 100644 --- a/application/Espo/ORM/Repository/RDBRepository.php +++ b/application/Espo/ORM/Repository/RDBRepository.php @@ -94,9 +94,12 @@ class RDBRepository implements Repository */ public function getNew(): Entity { + /** @var T $entity */ $entity = $this->entityFactory->create($this->entityType); - $entity->populateDefaults(); + if ($entity instanceof BaseEntity) { + $entity->populateDefaults(); + } return $entity; } @@ -115,7 +118,10 @@ class RDBRepository implements Repository ]) ->build(); - return $this->getMapper()->selectOne($selectQuery); + /** @var T $entity */ + $entity = $this->getMapper()->selectOne($selectQuery); + + return $entity; } /**