Skip to content

Commit 6a5dd2b

Browse files
committed
indexBy does not refer to attributes, but to column names
1 parent f8b53f4 commit 6a5dd2b

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

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;

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

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)