diff --git a/application/Espo/ORM/Defs/FieldDefs.php b/application/Espo/ORM/Defs/FieldDefs.php index d983b45327..26f590cfc7 100644 --- a/application/Espo/ORM/Defs/FieldDefs.php +++ b/application/Espo/ORM/Defs/FieldDefs.php @@ -29,6 +29,8 @@ namespace Espo\ORM\Defs; +use RuntimeException; + /** * Field definitions. */ @@ -66,7 +68,13 @@ class FieldDefs */ public function getType(): string { - return $this->data['type']; + $type = $this->data['type'] ?? null; + + if ($type === null) { + throw new RuntimeException("Field '{$this->name}' has no type."); + } + + return $type; } /** diff --git a/application/Espo/ORM/Defs/RelationDefs.php b/application/Espo/ORM/Defs/RelationDefs.php index a394c11f36..590980c533 100644 --- a/application/Espo/ORM/Defs/RelationDefs.php +++ b/application/Espo/ORM/Defs/RelationDefs.php @@ -70,7 +70,13 @@ class RelationDefs */ public function getType(): string { - return $this->data['type']; + $type = $this->data['type'] ?? null; + + if ($type === null) { + throw new RuntimeException("Relation '{$this->name}' has no type."); + } + + return $type; } /**