From 95a8dc2742da85f4e58d623ed14970a9a55fea09 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 14 Nov 2024 18:39:27 +0200 Subject: [PATCH] deferred load --- .../Espo/ORM/Relation/RDBRelations.php | 5 ++++- schema/metadata/entityDefs.json | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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." + } + } + } } ] },