From 83ced0d58ffcd6236a56fa9f81be0ee0d66ddf70 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 2 Dec 2021 12:54:17 +0200 Subject: [PATCH] orm defs: no type exception --- application/Espo/ORM/Defs/FieldDefs.php | 10 +++++++++- application/Espo/ORM/Defs/RelationDefs.php | 8 +++++++- 2 files changed, 16 insertions(+), 2 deletions(-) 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; } /**