10000 bug #38604 [DoctrineBridge] indexBy does not refer to attributes, but… · symfony/symfony@9761609 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9761609

Browse files
committed
bug #38604 [DoctrineBridge] indexBy does not refer to attributes, but to column names (xabbuh)
This PR was merged into the 3.4 branch. Discussion ---------- [DoctrineBridge] indexBy does not refer to attributes, but to column names | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #37982 | License | MIT | Doc PR | Commits ------- af1a620 indexBy does not refer to attributes, but to column names
2 parents 4b4abc3 + af1a620 commit 9761609

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -110,19 +110,10 @@ public function getTypes($class, $property, array $context = [])
110110
$associationMapping = $metadata->getAssociationMapping($property);
111111

112112
if (isset($associationMapping['indexBy'])) {
113-
$indexProperty = $associationMapping['indexBy'];
113+
$indexColumn = $associationMapping['indexBy'];
114114
/** @var ClassMetadataInfo $subMetadata */
115115
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
116-
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
117-
118-
if (null === $typeOfField) {
119-
$associationMapping = $subMetadata->getAssociationMapping($indexProperty);
120-
121-
/** @var ClassMetadataInfo $subMetadata */
122-
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($indexProperty);
123-
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
124-
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
125-
}
116+
$typeOfField = $subMetadata->getTypeOfField($subMetadata->getFieldForColumn($indexColumn));
126117

127118
if (!$collectionKeyType = $this->getPhpType($typeOfField)) {
128119
return null;

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineDummy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class DoctrineDummy
4242
public $bar;
4343

4444
/**
45-
* @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid")
45+
* @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid_column")
4646
*/
4747
protected $indexedBar;
4848

src/Symfony/Bridge/Doctrine/Tests/PropertyInfo/Fixtures/DoctrineRelation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DoctrineRelation
3030
public $id;
3131

3232
/**
33-
* @Column(type="guid")
33+
* @Column(type="guid", name="rguid_column")
3434
*/
3535
protected $rguid;
3636

0 commit comments

Comments
 (0)
0