From d4ab9850f2923ee03e5df79b4d9ab7dffb276aa9 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sat, 1 Jul 2023 20:22:21 +0300 Subject: [PATCH] orm metadata fields => attributes --- .../Espo/Core/ORM/MetadataDataProvider.php | 2 +- .../Metadata/CategoryTree/entityDefs.json | 2 +- .../Core/Utils/Database/Orm/Converter.php | 91 +- .../Utils/Database/Orm/Defs/EntityDefs.php | 3 +- .../metadata/entityDefs/DocumentFolder.json | 2 +- .../entityDefs/KnowledgeBaseCategory.json | 2 +- application/Espo/ORM/BaseEntity.php | 2 +- application/Espo/ORM/Defs/EntityDefs.php | 6 +- .../entityDefs/EmailTemplateCategory.json | 2 +- .../Espo/Core/Mail/FiltersMatcherTest.php | 4 +- .../Database/Orm/Defs/EntityDefsTest.php | 2 +- tests/unit/Espo/Entities/EmailTest.php | 286 +++---- tests/unit/Espo/ORM/DefsTest.php | 8 +- .../testData/Core/Mail/attachment_defs.php | 144 ++-- tests/unit/testData/Core/Mail/email_defs.php | 786 +++++++++--------- tests/unit/testData/DB/ormMetadata.php | 34 +- 16 files changed, 691 insertions(+), 685 deletions(-) diff --git a/application/Espo/Core/ORM/MetadataDataProvider.php b/application/Espo/Core/ORM/MetadataDataProvider.php index a3251e15a0..fd9bca4684 100644 --- a/application/Espo/Core/ORM/MetadataDataProvider.php +++ b/application/Espo/Core/ORM/MetadataDataProvider.php @@ -45,7 +45,7 @@ class MetadataDataProvider implements MetadataDataProviderInterface $data = $this->ormMetadataData->getData(); foreach (array_keys($data) as $entityType) { - $data[$entityType]['vFields'] = $this->metadata->get(['entityDefs', $entityType, 'fields']) ?? []; + $data[$entityType]['fields'] = $this->metadata->get(['entityDefs', $entityType, 'fields']) ?? []; } return $data; diff --git a/application/Espo/Core/Templates/Metadata/CategoryTree/entityDefs.json b/application/Espo/Core/Templates/Metadata/CategoryTree/entityDefs.json index f31b4a235b..2a535ac4e7 100644 --- a/application/Espo/Core/Templates/Metadata/CategoryTree/entityDefs.json +++ b/application/Espo/Core/Templates/Metadata/CategoryTree/entityDefs.json @@ -85,7 +85,7 @@ }, "additionalTables": { "{entityType}Path": { - "fields": { + "attributes": { "id": { "type": "id", "dbType": "integer", diff --git a/application/Espo/Core/Utils/Database/Orm/Converter.php b/application/Espo/Core/Utils/Database/Orm/Converter.php index e60fb83d25..fae46aeefc 100644 --- a/application/Espo/Core/Utils/Database/Orm/Converter.php +++ b/application/Espo/Core/Utils/Database/Orm/Converter.php @@ -92,15 +92,8 @@ class Converter /** @var array */ private array $idParams = []; - /** - * Permitted entityDefs parameters which will be copied to ormMetadata. - * - * @var string[] - */ - private array $permittedEntityOptions = [ - 'indexes', - 'additionalTables', - ]; + /** @var string[] */ + private array $copyEntityProperties = ['indexes']; private IndexHelper $indexHelper; @@ -167,11 +160,13 @@ class Converter $ormMetadata, $this->createEntityTypesFromRelations($entityType, $entityOrmMetadata) ); + } + foreach ($entityDefs as $entityMetadata) { /** @var array> $ormMetadata */ $ormMetadata = Util::merge( $ormMetadata, - $this->createAdditionalEntityTypes($entityOrmMetadata) + $this->obtainAdditionalTablesOrmMetadata($entityMetadata) ); } @@ -194,17 +189,17 @@ class Converter $ormMetadata = []; $ormMetadata[$entityType] = [ - 'fields' => [], + 'attributes' => [], 'relations' => [], ]; - foreach ($this->permittedEntityOptions as $optionName) { + foreach ($this->copyEntityProperties as $optionName) { if (isset($entityMetadata[$optionName])) { $ormMetadata[$entityType][$optionName] = $entityMetadata[$optionName]; } } - $ormMetadata[$entityType]['fields'] = $this->convertFields($entityType, $entityMetadata); + $ormMetadata[$entityType]['attributes'] = $this->convertFields($entityType, $entityMetadata); $ormMetadata = $this->correctFields($entityType, $ormMetadata); @@ -224,7 +219,7 @@ class Converter $ormMetadata[$entityType]['collection']['orderBy'] = $collectionDefs['orderByColumn']; } else if (array_key_exists('orderBy', $collectionDefs)) { - if (array_key_exists($collectionDefs['orderBy'], $ormMetadata[$entityType]['fields'])) { + if (array_key_exists($collectionDefs['orderBy'], $ormMetadata[$entityType]['attributes'])) { $ormMetadata[$entityType]['collection']['orderBy'] = $collectionDefs['orderBy']; } } @@ -245,15 +240,18 @@ class Converter */ private function afterFieldsProcess(array $ormMetadata): array { - foreach ($ormMetadata as $entityType => &$entityParams) { - foreach ($entityParams['fields'] as $attribute => &$attributeParams) { + foreach ($ormMetadata as /*$entityType =>*/ &$entityParams) { + if (empty($entityParams['attributes'])) { + print_r($entityParams); + } + foreach ($entityParams['attributes'] as $attribute => &$attributeParams) { // Remove fields without type. if ( !isset($attributeParams['type']) && (!isset($attributeParams['notStorable']) || $attributeParams['notStorable'] === false) ) { - unset($entityParams['fields'][$attribute]); + unset($entityParams['attributes'][$attribute]); continue; } @@ -316,7 +314,7 @@ class Converter private function afterProcess(array $ormMetadata): array { foreach ($ormMetadata as $entityType => &$entityParams) { - foreach ($entityParams['fields'] as $attribute => &$attributeParams) { + foreach ($entityParams['attributes'] as $attribute => &$attributeParams) { $attributeType = $attributeParams['type'] ?? null; switch ($attributeType) { @@ -337,7 +335,7 @@ class Converter */ private function obtainForeignType(array $data, string $entityType, string $attribute): ?string { - $params = $data[$entityType]['fields'][$attribute] ?? []; + $params = $data[$entityType]['attributes'][$attribute] ?? []; $foreign = $params['foreign'] ?? null; $relation = $params['relation'] ?? null; @@ -354,7 +352,7 @@ class Converter return null; } - $foreignParams = $data[$foreignEntityType]['fields'][$foreign] ?? []; + $foreignParams = $data[$foreignEntityType]['attributes'][$foreign] ?? []; return $foreignParams['type'] ?? null; } @@ -397,7 +395,7 @@ class Converter $fieldTypeMetadata = $this->metadataHelper->getFieldDefsByType($attributeParams); - $fieldDefs = $this->convertField($entityType, $attribute, $attributeParams, $fieldTypeMetadata); + $fieldDefs = $this->convertField($attributeParams, $fieldTypeMetadata); if ($fieldDefs !== false) { if (isset($output[$attribute]) && !in_array($attribute, $unmergedFields)) { @@ -442,23 +440,23 @@ class Converter { $entityMetadata = $ormMetadata[$entityType]; - foreach ($entityMetadata['fields'] as $field => $fieldParams) { - $fieldType = $fieldParams['type'] ?? null; + foreach ($entityMetadata['attributes'] as $field => $itemParams) { + $type = $itemParams['type'] ?? null; - if (!$fieldType) { + if (!$type) { continue; } /** @var ?class-string $className */ - $className = $this->metadata->get(['fields', $fieldType, 'converterClassName']); + $className = $this->metadata->get(['fields', $type, 'converterClassName']); if ($className) { $toUnset = - !in_array('', $this->metadata->get(['fields', $fieldType, 'actualFields']) ?? []) && - !in_array('', $this->metadata->get(['fields', $fieldType, 'notActualFields']) ?? []); + !in_array('', $this->metadata->get(['fields', $type, 'actualFields']) ?? []) && + !in_array('', $this->metadata->get(['fields', $type, 'notActualFields']) ?? []); if ($toUnset) { - $ormMetadata = Util::unsetInArray($ormMetadata, [$entityType => ['fields.' . $field]]); + $ormMetadata = Util::unsetInArray($ormMetadata, [$entityType => ['attributes.' . $field]]); } $converter = $this->injectableFactory->create($className); @@ -480,7 +478,7 @@ class Converter if ($defaultAttributes && array_key_exists($field, $defaultAttributes)) { $defaultMetadataPart = [ $entityType => [ - 'fields' => [ + 'attributes' => [ $field => [ 'default' => $defaultAttributes[$field], ] @@ -499,19 +497,19 @@ class Converter if ($scopeDefs['stream'] ?? false) { if (!isset($entityMetadata['fields']['isFollowed'])) { - $ormMetadata[$entityType]['fields']['isFollowed'] = [ + $ormMetadata[$entityType]['attributes']['isFollowed'] = [ 'type' => Entity::VARCHAR, 'notStorable' => true, 'notExportable' => true, ]; - $ormMetadata[$entityType]['fields']['followersIds'] = [ + $ormMetadata[$entityType]['attributes']['followersIds'] = [ 'type' => Entity::JSON_ARRAY, 'notStorable' => true, 'notExportable' => true, ]; - $ormMetadata[$entityType]['fields']['followersNames'] = [ + $ormMetadata[$entityType]['attributes']['followersNames'] = [ 'type' => Entity::JSON_OBJECT, 'notStorable' => true, 'notExportable' => true, @@ -521,7 +519,7 @@ class Converter // @todo Refactor. if ($this->metadata->get(['entityDefs', $entityType, 'optimisticConcurrencyControl'])) { - $ormMetadata[$entityType]['fields']['versionNumber'] = [ + $ormMetadata[$entityType]['attributes']['versionNumber'] = [ 'type' => Entity::INT, 'dbType' => Types::BIGINT, 'notExportable' => true, @@ -537,8 +535,6 @@ class Converter * @return array|false */ private function convertField( - string $entityType, - string $field, array $fieldParams, ?array $fieldTypeMetadata = null ) { @@ -742,8 +738,8 @@ class Converter $defs['indexes'] ??= []; - if (isset($defs['fields'])) { - $indexList = self::getEntityIndexListFromAttributes($defs['fields']); + if (isset($defs['attributes'])) { + $indexList = self::getEntityIndexListFromAttributes($defs['attributes']); foreach ($indexList as $indexName => $indexParams) { if (!isset($defs['indexes'][$indexName])) { @@ -824,7 +820,7 @@ class Converter * @param array $defs * @return array */ - private function createAdditionalEntityTypes(array $defs): array + private function obtainAdditionalTablesOrmMetadata(array $defs): array { /** @var array> $additionalDefs */ $additionalDefs = $defs['additionalTables'] ?? []; @@ -840,6 +836,17 @@ class Converter $this->applyIndexes($additionalDefs, $itemEntityType); } + // For backward compatibility. Actual as of v8.0. + // @todo Remove in v10.0. + // @todo Add deprecation warning in v9.0. If 'fields' is set. + foreach ($additionalDefs as &$entityDefs) { + if (!isset($entityDefs['attributes'])) { + $entityDefs['attributes'] = $entityDefs['fields'] ?? []; + + unset($entityDefs['fields']); + } + } + return $additionalDefs; } @@ -862,7 +869,7 @@ class Converter $itemDefs = [ 'skipRebuild' => true, - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, 'autoincrement' => true, @@ -876,7 +883,7 @@ class Converter if (!$relationDefs->hasMidKey()) { throw new LogicException( - "Bad manyMany relation {$name} in {$entityType}. Might be not defined on the other side."); + "Bad manyMany relation $name in $entityType. Might be not defined on the other side."); } $key1 = $relationDefs->getMidKey(); @@ -885,7 +892,7 @@ class Converter $midKeys = [$key1, $key2]; foreach ($midKeys as $key) { - $itemDefs['fields'][$key] = [ + $itemDefs['attributes'][$key] = [ 'type' => Entity::FOREIGN_ID, ]; } @@ -907,7 +914,7 @@ class Converter $columnDefs['default'] = $attributeDefs->getParam('default'); } - $itemDefs['fields'][$columnName] = $columnDefs; + $itemDefs['attributes'][$columnName] = $columnDefs; } foreach ($relationDefs->getIndexList() as $indexDefs) { diff --git a/application/Espo/Core/Utils/Database/Orm/Defs/EntityDefs.php b/application/Espo/Core/Utils/Database/Orm/Defs/EntityDefs.php index 9a818a50d1..9855c9bada 100644 --- a/application/Espo/Core/Utils/Database/Orm/Defs/EntityDefs.php +++ b/application/Espo/Core/Utils/Database/Orm/Defs/EntityDefs.php @@ -125,8 +125,7 @@ class EntityDefs $attributesData[$name] = $attributeDefs->toAssoc(); } - // @todo Change to attributes. - $data['fields'] = $attributesData; + $data['attributes'] = $attributesData; } if (count($this->relations)) { diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json index d15470c87d..b372c66b89 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/DocumentFolder.json @@ -81,7 +81,7 @@ }, "additionalTables": { "DocumentFolderPath": { - "fields": { + "attributes": { "id": { "type": "id", "dbType": "integer", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json index d8280b1b1d..59f4656529 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseCategory.json @@ -88,7 +88,7 @@ }, "additionalTables": { "KnowledgeBaseCategoryPath": { - "fields": { + "attributes": { "id": { "type": "id", "dbType": "integer", diff --git a/application/Espo/ORM/BaseEntity.php b/application/Espo/ORM/BaseEntity.php index 72ceb73a92..f2ee721fd3 100644 --- a/application/Espo/ORM/BaseEntity.php +++ b/application/Espo/ORM/BaseEntity.php @@ -85,7 +85,7 @@ class BaseEntity implements Entity $this->entityType = $entityType; $this->entityManager = $entityManager; - $this->attributes = $defs['attributes'] ?? $defs['fields'] ?? $this->attributes; + $this->attributes = $defs['attributes'] /*?? $defs['fields']*/ ?? $this->attributes; $this->relations = $defs['relations'] ?? $this->relations; if ($valueAccessorFactory) { diff --git a/application/Espo/ORM/Defs/EntityDefs.php b/application/Espo/ORM/Defs/EntityDefs.php index 8b97320b0b..4006369c91 100644 --- a/application/Espo/ORM/Defs/EntityDefs.php +++ b/application/Espo/ORM/Defs/EntityDefs.php @@ -76,7 +76,7 @@ class EntityDefs public function getAttributeNameList(): array { /** @var string[] */ - return array_keys($this->data['attributes'] ?? $this->data['fields'] ?? []); + return array_keys($this->data['attributes']); } /** @@ -109,7 +109,7 @@ class EntityDefs public function getFieldNameList(): array { /** @var string[] */ - return array_keys($this->data['vFields'] ?? []); + return array_keys($this->data['fields'] ?? []); } /** @@ -419,7 +419,7 @@ class EntityDefs private function loadField(string $name): ?FieldDefs { - $raw = $this->data['vFields'][$name] ?? /*$this->data['fields'][$name] ??*/ null; + $raw = $this->data['fields'][$name] ?? null; if (!$raw) { return null; diff --git a/application/Espo/Resources/metadata/entityDefs/EmailTemplateCategory.json b/application/Espo/Resources/metadata/entityDefs/EmailTemplateCategory.json index 69487a09c2..b79bd35224 100644 --- a/application/Espo/Resources/metadata/entityDefs/EmailTemplateCategory.json +++ b/application/Espo/Resources/metadata/entityDefs/EmailTemplateCategory.json @@ -77,7 +77,7 @@ }, "additionalTables": { "EmailTemplateCategoryPath": { - "fields": { + "attributes": { "id": { "type": "id", "dbType": "integer", diff --git a/tests/unit/Espo/Core/Mail/FiltersMatcherTest.php b/tests/unit/Espo/Core/Mail/FiltersMatcherTest.php index fc149b425a..a81089522e 100644 --- a/tests/unit/Espo/Core/Mail/FiltersMatcherTest.php +++ b/tests/unit/Espo/Core/Mail/FiltersMatcherTest.php @@ -45,7 +45,7 @@ class FiltersMatcherTest extends \PHPUnit\Framework\TestCase $this->entityManager = $this->createMock(EntityManager::class); $this->emailDefs = [ - 'fields' => [ + 'attributes' => [ 'from' => [ 'type' => 'varchar' ], @@ -68,7 +68,7 @@ class FiltersMatcherTest extends \PHPUnit\Framework\TestCase ]; $this->filterDefs = [ - 'fields' => [ + 'attributes' => [ 'from' => [ 'type' => 'varchar' ], diff --git a/tests/unit/Espo/Core/Utils/Database/Orm/Defs/EntityDefsTest.php b/tests/unit/Espo/Core/Utils/Database/Orm/Defs/EntityDefsTest.php index e47caab1d6..17e853edef 100644 --- a/tests/unit/Espo/Core/Utils/Database/Orm/Defs/EntityDefsTest.php +++ b/tests/unit/Espo/Core/Utils/Database/Orm/Defs/EntityDefsTest.php @@ -55,7 +55,7 @@ class EntityDefsTest extends TestCase ->withIndex($i1); $this->assertEquals([ - 'fields' => [ + 'attributes' => [ 'a1' => $a1->toAssoc(), 'a2' => $a2->toAssoc(), ], diff --git a/tests/unit/Espo/Entities/EmailTest.php b/tests/unit/Espo/Entities/EmailTest.php index 97d3f2c12a..908b70f372 100644 --- a/tests/unit/Espo/Entities/EmailTest.php +++ b/tests/unit/Espo/Entities/EmailTest.php @@ -39,387 +39,387 @@ class EmailTest extends \PHPUnit\Framework\TestCase private $email; // TODO defs test helper - protected $defs = array( - 'fields' => - array ( + protected $defs = [ + 'attributes' => + [ 'id' => - array ( + [ 'type' => 'id', 'dbType' => 'varchar', 'len' => '24', - ), + ], 'name' => - array ( + [ 'type' => 'varchar', 'len' => 255, - ), + ], 'subject' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), + ], 'fromName' => - array ( + [ 'type' => 'varchar', 'len' => 255, - ), + ], 'from' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), + ], 'to' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), + ], 'cc' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), + ], 'bcc' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), + ], 'replyTo' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), + ], 'emailAddress' => - array ( + [ 'type' => 'base', 'notStorable' => true, - ), + ], 'bodyPlain' => - array ( + [ 'type' => 'text', - ), + ], 'body' => - array ( + [ 'type' => 'text', - ), + ], 'isHtml' => - array ( + [ 'type' => 'bool', 'default' => true, - ), + ], 'status' => - array ( + [ 'type' => 'varchar', 'default' => 'Archived', 'len' => 255, - ), + ], 'parent' => - array ( + [ 'type' => 'linkParent', 'notStorable' => true, - ), + ], 'dateSent' => - array ( + [ 'type' => 'datetime', 'notNull' => false, - ), + ], 'createdAt' => - array ( + [ 'type' => 'datetime', 'notNull' => false, - ), + ], 'modifiedAt' => - array ( + [ 'type' => 'datetime', 'notNull' => false, - ), + ], 'deleted' => - array ( + [ 'type' => 'bool', 'default' => false, - ), + ], 'bccEmailAddressesIds' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'bccEmailAddressesNames' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'ccEmailAddressesIds' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'ccEmailAddressesNames' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'toEmailAddressesIds' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'toEmailAddressesNames' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'fromEmailAddressName' => - array ( + [ 'type' => 'foreign', 'relation' => 'fromEmailAddress', 'foreign' => 'name', - ), + ], 'fromEmailAddressId' => - array ( + [ 'type' => 'foreignId', 'index' => true, 'dbType' => 'varchar', 'len' => '24', 'notNull' => false, - ), + ], 'attachmentsIds' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'attachmentsNames' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'assignedUserName' => - array ( + [ 'type' => 'foreign', 'relation' => 'assignedUser', 'foreign' => - array ( + [ 0 => 'firstName', 1 => ' ', 2 => 'lastName', - ), - ), + ], + ], 'assignedUserId' => - array ( + [ 'type' => 'foreignId', 'index' => true, 'dbType' => 'varchar', 'len' => '24', 'notNull' => false, - ), + ], 'modifiedByName' => - array ( + [ 'type' => 'foreign', 'relation' => 'modifiedBy', 'foreign' => - array ( + [ 0 => 'firstName', 1 => ' ', 2 => 'lastName', - ), - ), + ], + ], 'modifiedById' => - array ( + [ 'type' => 'foreignId', 'index' => true, 'dbType' => 'varchar', 'len' => '24', 'notNull' => false, - ), + ], 'createdByName' => - array ( + [ 'type' => 'foreign', 'relation' => 'createdBy', 'foreign' => - array ( + [ 0 => 'firstName', 1 => ' ', 2 => 'lastName', - ), - ), + ], + ], 'createdById' => - array ( + [ 'type' => 'foreignId', 'index' => true, 'dbType' => 'varchar', 'len' => '24', 'notNull' => false, - ), + ], 'parentId' => - array ( + [ 'type' => 'foreignId', 'index' => 'parent', 'dbType' => 'varchar', 'len' => '24', 'notNull' => false, - ), + ], 'parentType' => - array ( + [ 'type' => 'foreignType', 'notNull' => false, 'index' => 'parent', 'dbType' => 'varchar', 'len' => 255, - ), + ], 'parentName' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'teamsIds' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), + ], 'teamsNames' => - array ( + [ 'type' => 'varchar', 'notStorable' => true, - ), - ), + ], + ], 'relations' => - array ( + [ 'bccEmailAddresses' => - array ( + [ 'type' => 'manyMany', 'entity' => 'EmailAddress', 'foreignKey' => 'id', 'midKeys' => - array ( + [ 0 => 'emailId', 1 => 'emailAddressId', - ), + ], 'relationName' => 'EmailEmailAddress', 'conditions' => - array ( + [ 'addressType' => 'bcc', - ), + ], 'additionalColumns' => - array ( + [ 'addressType' => - array ( + [ 'type' => 'varchar', 'len' => '4', - ), - ), - ), + ], + ], + ], 'ccEmailAddresses' => - array ( + [ 'type' => 'manyMany', 'entity' => 'EmailAddress', 'foreignKey' => 'id', 'midKeys' => - array ( + [ 0 => 'emailId', 1 => 'emailAddressId', - ), + ], 'relationName' => 'EmailEmailAddress', 'conditions' => - array ( + [ 'addressType' => 'cc', - ), + ], 'additionalColumns' => - array ( + [ 'addressType' => - array ( + [ 'type' => 'varchar', 'len' => '4', - ), - ), - ), + ], + ], + ], 'toEmailAddresses' => - array ( + [ 'type' => 'manyMany', 'entity' => 'EmailAddress', 'foreignKey' => 'id', 'midKeys' => - array ( + [ 0 => 'emailId', 1 => 'emailAddressId', - ), + ], 'relationName' => 'EmailEmailAddress', 'conditions' => - array ( + [ 'addressType' => 'to', - ), + ], 'additionalColumns' => - array ( + [ 'addressType' => - array ( + [ 'type' => 'varchar', 'len' => '4', - ), - ), - ), + ], + ], + ], 'fromEmailAddress' => - array ( + [ 'type' => 'belongsTo', 'entity' => 'EmailAddress', 'key' => 'fromEmailAddressId', 'foreignKey' => 'id', - ), + ], 'attachments' => - array ( + [ 'type' => 'hasChildren', 'entity' => 'Attachment', 'foreignKey' => 'parentId', 'foreignType' => 'parentType', - ), + ], 'teams' => - array ( + [ 'type' => 'manyMany', 'entity' => 'Team', 'relationName' => 'entityTeam', 'midKeys' => - array ( + [ 0 => 'entity_id', 1 => 'team_id', - ), + ], 'conditions' => - array ( + [ 'entityType' => 'Email', - ), + ], 'additionalColumns' => - array ( + [ 'entityType' => - array ( + [ 'type' => 'varchar', 'len' => 100, - ), - ), - ), + ], + ], + ], 'assignedUser' => - array ( + [ 'type' => 'belongsTo', 'entity' => 'User', 'key' => 'assignedUserId', 'foreignKey' => 'id', - ), + ], 'modifiedBy' => - array ( + [ 'type' => 'belongsTo', 'entity' => 'User', 'key' => 'modifiedById', 'foreignKey' => 'id', - ), + ], 'createdBy' => - array ( + [ 'type' => 'belongsTo', 'entity' => 'User', 'key' => 'createdById', 'foreignKey' => 'id', - ), - ), - ); + ], + ], + ]; protected function setUp() : void diff --git a/tests/unit/Espo/ORM/DefsTest.php b/tests/unit/Espo/ORM/DefsTest.php index c2fe5ee60f..88a2037210 100644 --- a/tests/unit/Espo/ORM/DefsTest.php +++ b/tests/unit/Espo/ORM/DefsTest.php @@ -199,7 +199,7 @@ class DefsTest extends \PHPUnit\Framework\TestCase { $data = [ 'Test' => [ - 'fields' => [], + 'attributes' => [], ], ]; @@ -252,7 +252,7 @@ class DefsTest extends \PHPUnit\Framework\TestCase { $data = [ 'Test' => [ - 'fields' => [], + 'attributes' => [], ], ]; @@ -269,7 +269,7 @@ class DefsTest extends \PHPUnit\Framework\TestCase { $data = [ 'Test' => [ - 'vFields' => [ + 'fields' => [ 'f1' => [ 'type' => 'varchar', 'length' => 100, @@ -302,7 +302,7 @@ class DefsTest extends \PHPUnit\Framework\TestCase { $data = [ 'Test' => [ - 'fields' => [], + 'attributes' => [], ], ]; diff --git a/tests/unit/testData/Core/Mail/attachment_defs.php b/tests/unit/testData/Core/Mail/attachment_defs.php index 1ae3ac3a81..a851b6d3f6 100644 --- a/tests/unit/testData/Core/Mail/attachment_defs.php +++ b/tests/unit/testData/Core/Mail/attachment_defs.php @@ -1,138 +1,138 @@ array( - 'id' => - array ( +return [ + 'attributes' => [ + 'id' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'id', - ), - 'name' => - array ( + ], + 'name' => + [ 'type' => 'varchar', 'len' => 255, - ), - 'deleted' => - array ( + ], + 'deleted' => + [ 'type' => 'bool', 'default' => false, - ), - 'type' => - array ( + ], + 'type' => + [ 'type' => 'varchar', 'len' => 100, - ), - 'size' => - array ( + ], + 'size' => + [ 'type' => 'int', 'len' => 11, - ), - 'sourceId' => - array ( + ], + 'sourceId' => + [ 'type' => 'varchar', 'len' => 36, - ), - 'createdAt' => - array ( + ], + 'createdAt' => + [ 'type' => 'datetime', 'notNull' => false, - ), - 'contents' => - array ( + ], + 'contents' => + [ 'type' => 'text', 'notStorable' => true, - ), - 'role' => - array ( + ], + 'role' => + [ 'type' => 'varchar', 'len' => 36, - ), - 'global' => - array ( + ], + 'global' => + [ 'type' => 'bool', 'default' => false, - ), - 'parentId' => - array ( + ], + 'parentId' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => 'parent', 'notNull' => false, - ), - 'parentType' => - array ( + ], + 'parentType' => + [ 'type' => 'foreignType', 'notNull' => false, 'index' => 'parent', 'len' => 100, 'dbType' => 'varchar', - ), - 'parentName' => - array ( + ], + 'parentName' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'relatedId' => - array ( + ], + 'relatedId' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => 'related', 'notNull' => false, - ), - 'relatedType' => - array ( + ], + 'relatedType' => + [ 'type' => 'foreignType', 'notNull' => false, 'index' => 'related', 'len' => 100, 'dbType' => 'varchar', - ), - 'relatedName' => - array ( + ], + 'relatedName' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'createdById' => - array ( + ], + 'createdById' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => true, 'notNull' => false, - ), - 'createdByName' => - array ( + ], + 'createdByName' => + [ 'type' => 'foreign', 'notStorable' => false, 'relation' => 'createdBy', - 'foreign' => - array ( + 'foreign' => + [ 0 => 'firstName', 1 => ' ', 2 => 'lastName', - ), - ), - ), - 'relations' => array( - 'related' => - array ( + ], + ], + ], + 'relations' => [ + 'related' => + [ 'type' => 'belongsToParent', 'key' => 'relatedId', - ), - 'parent' => - array ( + ], + 'parent' => + [ 'type' => 'belongsToParent', 'key' => 'parentId', - ), - 'createdBy' => - array ( + ], + 'createdBy' => + [ 'type' => 'belongsTo', 'entity' => 'User', 'key' => 'createdById', 'foreignKey' => 'id', - ), - ) -); + ], + ] +]; diff --git a/tests/unit/testData/Core/Mail/email_defs.php b/tests/unit/testData/Core/Mail/email_defs.php index c131e6e3b4..e4c6c67ffb 100644 --- a/tests/unit/testData/Core/Mail/email_defs.php +++ b/tests/unit/testData/Core/Mail/email_defs.php @@ -1,117 +1,117 @@ array( - 'id' => - array ( +return [ + 'attributes' => [ + 'id' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'id', - ), - 'name' => - array ( + ], + 'name' => + [ 'type' => 'varchar', 'len' => 255, - ), - 'deleted' => - array ( + ], + 'deleted' => + [ 'type' => 'bool', 'default' => false, - ), - 'subject' => - array ( + ], + 'subject' => + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), - 'fromName' => - array ( + ], + 'fromName' => + [ 'type' => 'varchar', 'len' => 255, - ), - 'fromString' => - array ( + ], + 'fromString' => + [ 'type' => 'varchar', 'len' => 255, - ), - 'replyToString' => - array ( + ], + 'replyToString' => + [ 'type' => 'varchar', 'len' => 255, - ), - 'from' => - array ( + ], + 'from' => + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), - 'to' => - array ( + ], + 'to' => + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), - 'cc' => - array ( + ], + 'cc' => + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), - 'bcc' => - array ( + ], + 'bcc' => + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), - 'replyTo' => - array ( + ], + 'replyTo' => + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), - 'personStringData' => - array ( + ], + 'personStringData' => + [ 'type' => 'varchar', 'notStorable' => true, 'len' => 255, - ), - 'isRead' => - array ( + ], + 'isRead' => + [ 'type' => 'bool', 'notStorable' => true, 'default' => true, - ), - 'isNotRead' => - array ( + ], + 'isNotRead' => + [ 'type' => 'bool', 'notStorable' => true, 'default' => false, - ), - 'isReplied' => - array ( + ], + 'isReplied' => + [ 'type' => 'bool', 'default' => false, - ), - 'isNotReplied' => - array ( + ], + 'isNotReplied' => + [ 'type' => 'bool', 'notStorable' => true, 'default' => false, - ), - 'isImportant' => - array ( + ], + 'isImportant' => + [ 'type' => 'bool', 'notStorable' => true, 'default' => false, - ), - 'inTrash' => - array ( + ], + 'inTrash' => + [ 'type' => 'bool', 'notStorable' => true, 'default' => false, - ), - 'folderId' => - array ( + ], + 'folderId' => + [ 'dbType' => 'varchar', 'len' => 255, 'type' => 'foreignId', @@ -119,616 +119,616 @@ return array( 'default' => '', 'index' => 'folder', 'notNull' => false, - ), - 'isUsers' => - array ( + ], + 'isUsers' => + [ 'type' => 'bool', 'notStorable' => true, 'default' => false, - ), - 'nameHash' => - array ( + ], + 'nameHash' => + [ 'type' => 'text', 'notStorable' => true, - ), - 'typeHash' => - array ( + ], + 'typeHash' => + [ 'type' => 'text', 'notStorable' => true, - ), - 'idHash' => - array ( + ], + 'idHash' => + [ 'type' => 'text', 'notStorable' => true, - ), - 'messageId' => - array ( + ], + 'messageId' => + [ 'type' => 'varchar', 'len' => 255, - ), - 'messageIdInternal' => - array ( + ], + 'messageIdInternal' => + [ 'type' => 'varchar', 'len' => 300, 'index' => true, - ), - 'emailAddress' => - array ( + ], + 'emailAddress' => + [ 'type' => 'base', 'notStorable' => true, - ), - 'bodyPlain' => - array ( + ], + 'bodyPlain' => + [ 'type' => 'text', - ), - 'body' => - array ( + ], + 'body' => + [ 'type' => 'text', - ), - 'isHtml' => - array ( + ], + 'isHtml' => + [ 'type' => 'bool', 'default' => true, - ), - 'status' => - array ( + ], + 'status' => + [ 'type' => 'varchar', 'default' => 'Archived', 'len' => 255, - ), - 'hasAttachment' => - array ( + ], + 'hasAttachment' => + [ 'type' => 'bool', 'default' => false, - ), - 'dateSent' => - array ( + ], + 'dateSent' => + [ 'type' => 'datetime', 'notNull' => false, - ), - 'deliveryDate' => - array ( + ], + 'deliveryDate' => + [ 'type' => 'datetime', 'notNull' => false, - ), - 'createdAt' => - array ( + ], + 'createdAt' => + [ 'type' => 'datetime', 'notNull' => false, - ), - 'modifiedAt' => - array ( + ], + 'modifiedAt' => + [ 'type' => 'datetime', 'notNull' => false, - ), - 'isSystem' => - array ( + ], + 'isSystem' => + [ 'type' => 'bool', 'default' => false, - ), - 'isJustSent' => - array ( + ], + 'isJustSent' => + [ 'type' => 'bool', 'notStorable' => true, 'default' => false, - ), - 'isBeingImported' => - array ( + ], + 'isBeingImported' => + [ 'type' => 'bool', 'notStorable' => true, 'default' => false, - ), - 'folderName' => - array ( + ], + 'folderName' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'fromEmailAddressId' => - array ( + ], + 'fromEmailAddressId' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => true, 'notNull' => false, - ), - 'fromEmailAddressName' => - array ( + ], + 'fromEmailAddressName' => + [ 'type' => 'foreign', 'notStorable' => false, 'relation' => 'fromEmailAddress', 'foreign' => 'name', - ), - 'toEmailAddressesIds' => - array ( + ], + 'toEmailAddressesIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'toEmailAddressesNames' => - array ( + ], + 'toEmailAddressesNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'ccEmailAddressesIds' => - array ( + ], + 'ccEmailAddressesIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'ccEmailAddressesNames' => - array ( + ], + 'ccEmailAddressesNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'attachmentsIds' => - array ( + ], + 'attachmentsIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'attachmentsNames' => - array ( + ], + 'attachmentsNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'parentId' => - array ( + ], + 'parentId' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => 'parent', 'notNull' => false, - ), - 'parentType' => - array ( + ], + 'parentType' => + [ 'type' => 'foreignType', 'notNull' => false, 'index' => 'parent', 'len' => 100, 'dbType' => 'varchar', - ), - 'parentName' => - array ( + ], + 'parentName' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'createdById' => - array ( + ], + 'createdById' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => true, 'notNull' => false, - ), - 'createdByName' => - array ( + ], + 'createdByName' => + [ 'type' => 'foreign', 'notStorable' => false, 'relation' => 'createdBy', - 'foreign' => - array ( + 'foreign' => + [ 0 => 'firstName', 1 => ' ', 2 => 'lastName', - ), - ), - 'sentById' => - array ( + ], + ], + 'sentById' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => true, 'notNull' => false, - ), - 'sentByName' => - array ( + ], + 'sentByName' => + [ 'type' => 'foreign', 'notStorable' => false, 'relation' => 'sentBy', - 'foreign' => - array ( + 'foreign' => + [ 0 => 'firstName', 1 => ' ', 2 => 'lastName', - ), - ), - 'modifiedById' => - array ( + ], + ], + 'modifiedById' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => true, 'notNull' => false, - ), - 'modifiedByName' => - array ( + ], + 'modifiedByName' => + [ 'type' => 'foreign', 'notStorable' => false, 'relation' => 'modifiedBy', - 'foreign' => - array ( + 'foreign' => + [ 0 => 'firstName', 1 => ' ', 2 => 'lastName', - ), - ), - 'assignedUserId' => - array ( + ], + ], + 'assignedUserId' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => true, 'notNull' => false, - ), - 'assignedUserName' => - array ( + ], + 'assignedUserName' => + [ 'type' => 'foreign', 'notStorable' => false, 'relation' => 'assignedUser', - 'foreign' => - array ( + 'foreign' => + [ 0 => 'firstName', 1 => ' ', 2 => 'lastName', - ), - ), - 'repliedId' => - array ( + ], + ], + 'repliedId' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => true, 'notNull' => false, - ), - 'repliedName' => - array ( + ], + 'repliedName' => + [ 'type' => 'foreign', 'notStorable' => false, 'relation' => 'replied', 'foreign' => 'name', - ), - 'repliesIds' => - array ( + ], + 'repliesIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'repliesNames' => - array ( + ], + 'repliesNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'teamsIds' => - array ( + ], + 'teamsIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'teamsNames' => - array ( + ], + 'teamsNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'usersIds' => - array ( + ], + 'usersIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'usersNames' => - array ( + ], + 'usersNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'usersColumns' => - array ( + ], + 'usersColumns' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'assignedUsersIds' => - array ( + ], + 'assignedUsersIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'assignedUsersNames' => - array ( + ], + 'assignedUsersNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'inboundEmailsIds' => - array ( + ], + 'inboundEmailsIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'inboundEmailsNames' => - array ( + ], + 'inboundEmailsNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'emailAccountsIds' => - array ( + ], + 'emailAccountsIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'emailAccountsNames' => - array ( + ], + 'emailAccountsNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'accountId' => - array ( + ], + 'accountId' => + [ 'dbType' => 'varchar', 'len' => 24, 'type' => 'foreignId', 'index' => true, 'notNull' => false, - ), - 'accountName' => - array ( + ], + 'accountName' => + [ 'type' => 'foreign', 'notStorable' => false, 'relation' => 'account', 'foreign' => 'name', - ), - 'bccEmailAddressesIds' => - array ( + ], + 'bccEmailAddressesIds' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'bccEmailAddressesNames' => - array ( + ], + 'bccEmailAddressesNames' => + [ 'type' => 'varchar', 'notStorable' => true, - ), - 'attachmentsTypes' => - array ( + ], + 'attachmentsTypes' => + [ 'type' => 'jsonObject', 'notStorable' => true, - ), - ), - 'relations' => array( - 'account' => - array ( + ], + ], + 'relations' => [ + 'account' => + [ 'type' => 'belongsTo', 'entity' => 'Account', 'key' => 'accountId', 'foreignKey' => 'id', - ), - 'emailAccounts' => - array ( + ], + 'emailAccounts' => + [ 'type' => 'manyMany', 'entity' => 'EmailAccount', 'relationName' => 'emailEmailAccount', 'key' => 'id', 'foreignKey' => 'id', - 'midKeys' => - array ( + 'midKeys' => + [ 0 => 'emailId', 1 => 'emailAccountId', - ), - ), - 'inboundEmails' => - array ( + ], + ], + 'inboundEmails' => + [ 'type' => 'manyMany', 'entity' => 'InboundEmail', 'relationName' => 'emailInboundEmail', 'key' => 'id', 'foreignKey' => 'id', - 'midKeys' => - array ( + 'midKeys' => + [ 0 => 'emailId', 1 => 'inboundEmailId', - ), - ), - 'bccEmailAddresses' => - array ( + ], + ], + 'bccEmailAddresses' => + [ 'type' => 'manyMany', 'entity' => 'EmailAddress', 'foreignKey' => 'id', - 'midKeys' => - array ( + 'midKeys' => + [ 0 => 'emailId', 1 => 'emailAddressId', - ), + ], 'relationName' => 'emailEmailAddress', - 'conditions' => - array ( + 'conditions' => + [ 'addressType' => 'bcc', - ), - 'additionalColumns' => - array ( - 'addressType' => - array ( + ], + 'additionalColumns' => + [ + 'addressType' => + [ 'type' => 'varchar', 'len' => '4', - ), - ), - ), - 'ccEmailAddresses' => - array ( + ], + ], + ], + 'ccEmailAddresses' => + [ 'type' => 'manyMany', 'entity' => 'EmailAddress', 'foreignKey' => 'id', - 'midKeys' => - array ( + 'midKeys' => + [ 0 => 'emailId', 1 => 'emailAddressId', - ), + ], 'relationName' => 'emailEmailAddress', - 'conditions' => - array ( + 'conditions' => + [ 'addressType' => 'cc', - ), - 'additionalColumns' => - array ( - 'addressType' => - array ( + ], + 'additionalColumns' => + [ + 'addressType' => + [ 'type' => 'varchar', 'len' => '4', - ), - ), - ), - 'toEmailAddresses' => - array ( + ], + ], + ], + 'toEmailAddresses' => + [ 'type' => 'manyMany', 'entity' => 'EmailAddress', 'foreignKey' => 'id', - 'midKeys' => - array ( + 'midKeys' => + [ 0 => 'emailId', 1 => 'emailAddressId', - ), + ], 'relationName' => 'emailEmailAddress', - 'conditions' => - array ( + 'conditions' => + [ 'addressType' => 'to', - ), - 'additionalColumns' => - array ( - 'addressType' => - array ( + ], + 'additionalColumns' => + [ + 'addressType' => + [ 'type' => 'varchar', 'len' => '4', - ), - ), - ), - 'fromEmailAddress' => - array ( + ], + ], + ], + 'fromEmailAddress' => + [ 'type' => 'belongsTo', 'entity' => 'EmailAddress', 'key' => 'fromEmailAddressId', 'foreignKey' => 'id', - ), - 'replies' => - array ( + ], + 'replies' => + [ 'type' => 'hasMany', 'entity' => 'Email', 'foreignKey' => 'repliedId', - ), - 'replied' => - array ( + ], + 'replied' => + [ 'type' => 'belongsTo', 'entity' => 'Email', 'key' => 'repliedId', 'foreignKey' => 'id', - ), - 'parent' => - array ( + ], + 'parent' => + [ 'type' => 'belongsToParent', 'key' => 'parentId', - ), - 'sentBy' => - array ( + ], + 'sentBy' => + [ 'type' => 'belongsTo', 'entity' => 'User', 'key' => 'sentById', 'foreignKey' => 'id', - ), - 'users' => - array ( + ], + 'users' => + [ 'type' => 'manyMany', 'entity' => 'User', 'relationName' => 'emailUser', 'key' => 'id', 'foreignKey' => 'id', - 'midKeys' => - array ( + 'midKeys' => + [ 0 => 'emailId', 1 => 'userId', - ), - 'additionalColumns' => - array ( - 'isRead' => - array ( + ], + 'additionalColumns' => + [ + 'isRead' => + [ 'type' => 'bool', 'default' => false, - ), - 'isImportant' => - array ( + ], + 'isImportant' => + [ 'type' => 'bool', 'default' => false, - ), - 'inTrash' => - array ( + ], + 'inTrash' => + [ 'type' => 'bool', 'default' => false, - ), - 'folderId' => - array ( + ], + 'folderId' => + [ 'type' => 'varchar', 'default' => NULL, 'maxLength' => 24, - ), - ), - ), - 'assignedUsers' => - array ( + ], + ], + ], + 'assignedUsers' => + [ 'type' => 'manyMany', 'entity' => 'User', 'relationName' => 'entityUser', - 'midKeys' => - array ( + 'midKeys' => + [ 0 => 'entityId', 1 => 'userId', - ), - 'conditions' => - array ( + ], + 'conditions' => + [ 'entityType' => 'Email', - ), - 'additionalColumns' => - array ( - 'entityType' => - array ( + ], + 'additionalColumns' => + [ + 'entityType' => + [ 'type' => 'varchar', 'len' => 100, - ), - ), - ), - 'teams' => - array ( + ], + ], + ], + 'teams' => + [ 'type' => 'manyMany', 'entity' => 'Team', 'relationName' => 'entityTeam', - 'midKeys' => - array ( + 'midKeys' => + [ 0 => 'entity_id', 1 => 'team_id', - ), - 'conditions' => - array ( + ], + 'conditions' => + [ 'entityType' => 'Email', - ), - 'additionalColumns' => - array ( - 'entityType' => - array ( + ], + 'additionalColumns' => + [ + 'entityType' => + [ 'type' => 'varchar', 'len' => 100, - ), - ), - ), - 'assignedUser' => - array ( + ], + ], + ], + 'assignedUser' => + [ 'type' => 'belongsTo', 'entity' => 'User', 'key' => 'assignedUserId', 'foreignKey' => 'id', - ), - 'modifiedBy' => - array ( + ], + 'modifiedBy' => + [ 'type' => 'belongsTo', 'entity' => 'User', 'key' => 'modifiedById', 'foreignKey' => 'id', - ), - 'createdBy' => - array ( + ], + 'createdBy' => + [ 'type' => 'belongsTo', 'entity' => 'User', 'key' => 'createdById', 'foreignKey' => 'id', - ), - 'attachments' => - array ( + ], + 'attachments' => + [ 'type' => 'hasChildren', 'entity' => 'Attachment', 'foreignKey' => 'parentId', 'foreignType' => 'parentType', 'relationName' => 'attachments', - ), - ) -); \ No newline at end of file + ], + ] +]; diff --git a/tests/unit/testData/DB/ormMetadata.php b/tests/unit/testData/DB/ormMetadata.php index a14ffb474f..5ce0006497 100644 --- a/tests/unit/testData/DB/ormMetadata.php +++ b/tests/unit/testData/DB/ormMetadata.php @@ -4,7 +4,7 @@ use Espo\ORM\Entity; return [ 'Account' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -41,7 +41,7 @@ return [ ], 'Team' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -60,7 +60,7 @@ return [ ], 'EntityTeam' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, 'autoincrement' => true, @@ -89,7 +89,7 @@ return [ ], 'Contact' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -120,7 +120,7 @@ return [ ], 'Post' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -195,7 +195,7 @@ return [ ], 'Comment' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -227,7 +227,7 @@ return [ ], 'PostData' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -251,7 +251,7 @@ return [ ], 'Tag' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -281,7 +281,7 @@ return [ ], 'PostTag' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, 'autoincrement' => true, @@ -316,7 +316,7 @@ return [ ], 'Note' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -349,7 +349,7 @@ return [ ], 'Article' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID ], @@ -371,7 +371,7 @@ return [ ], 'Job' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID ], @@ -400,7 +400,7 @@ return [ ], 'Test' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -437,7 +437,7 @@ return [ ], 'Dependee' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -459,7 +459,7 @@ return [ ], 'TestWhere' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -521,7 +521,7 @@ return [ ], 'TestSelect' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ], @@ -558,7 +558,7 @@ return [ ], 'TestSelectRight' => [ - 'fields' => [ + 'attributes' => [ 'id' => [ 'type' => Entity::ID, ],