From 6735469b082c8aa1e6750fdbb6b55e6f0cdc64c3 Mon Sep 17 00:00:00 2001 From: Ishiki Date: Sun, 16 Feb 2020 16:06:47 +0200 Subject: [PATCH] Use column_name attribute rather than fieldName In some cases if you try to keep update structure clean and use column_name attribute inside field config doctrine schema update breaks, because this builder tries to build index based on field name rather than column name. This PR fixes this issue. --- .../Bundle/EntityExtendBundle/ORM/IndexMetadataBuilder.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Oro/Bundle/EntityExtendBundle/ORM/IndexMetadataBuilder.php b/src/Oro/Bundle/EntityExtendBundle/ORM/IndexMetadataBuilder.php index 092961ae69e..226d1f3489b 100644 --- a/src/Oro/Bundle/EntityExtendBundle/ORM/IndexMetadataBuilder.php +++ b/src/Oro/Bundle/EntityExtendBundle/ORM/IndexMetadataBuilder.php @@ -46,13 +46,14 @@ public function build(ClassMetadataBuilder $metadataBuilder, ConfigInterface $ex $indices = $extendConfig->get('index'); // TODO: need to be changed to fieldName => columnName // TODO: should be done in scope https://magecore.atlassian.net/browse/BAP-3940 - foreach ($indices as $columnName => $indexType) { - $fieldConfig = $this->extendConfigProvider->getConfig($className, $columnName); + foreach ($indices as $fieldName => $indexType) { + $fieldConfig = $this->extendConfigProvider->getConfig($className, $fieldName); + $columnName = $fieldConfig->get('column_name', false, $fieldName); if ($indexType && !$fieldConfig->is('state', ExtendScope::STATE_NEW)) { $indexName = $this->nameGenerator->generateIndexNameForExtendFieldVisibleInGrid( $className, - $columnName + $fieldName ); if ((int)$indexType === IndexScope::INDEX_UNIQUE) { $metadataBuilder->addUniqueConstraint([$columnName], $indexName);