diff --git a/application/Espo/ORM/Relation/RDBRelations.php b/application/Espo/ORM/Relation/RDBRelations.php index f777061fe1..48c0730064 100644 --- a/application/Espo/ORM/Relation/RDBRelations.php +++ b/application/Espo/ORM/Relation/RDBRelations.php @@ -30,7 +30,6 @@ namespace Espo\ORM\Relation; use Espo\ORM\BaseEntity; -use Espo\ORM\Defs\RelationDefs; use Espo\ORM\Entity; use Espo\ORM\EntityCollection; use Espo\ORM\EntityManager; @@ -310,6 +309,10 @@ class RDBRelations implements Relations ->getEntity($this->entity->getEntityType()) ->getRelation($relation); + if (!$defs->getParam('deferredLoad')) { + return null; + } + $relationType = $defs->getType(); $id = null; diff --git a/schema/metadata/entityDefs.json b/schema/metadata/entityDefs.json index 41cc198eca..c94ecbe32c 100644 --- a/schema/metadata/entityDefs.json +++ b/schema/metadata/entityDefs.json @@ -1330,6 +1330,26 @@ } } } + }, + { + "if": { + "properties": { + "type": { + "anyOf": [ + {"const": "belongsTo"}, + {"const": "belongsToParent"} + ] + } + } + }, + "then": { + "properties": { + "deferredLoad": { + "type": "boolean", + "description": "When getting a related entity from an entity, it will be returned without loaded values. Values will be loaded on accessing. The downside is that it can return an entity even if it's deleted." + } + } + } } ] },