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
-------
af1a6208ec
indexBy does not refer to attributes, but to column names
This commit is contained in:
commit
976160914a
|
@ -110,19 +110,10 @@ class DoctrineExtractor implements PropertyListExtractorInterface, PropertyTypeE
|
|||
$associationMapping = $metadata->getAssociationMapping($property);
|
||||
|
||||
if (isset($associationMapping['indexBy'])) {
|
||||
$indexProperty = $associationMapping['indexBy'];
|
||||
$indexColumn = $associationMapping['indexBy'];
|
||||
/** @var ClassMetadataInfo $subMetadata */
|
||||
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
|
||||
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
|
||||
|
||||
if (null === $typeOfField) {
|
||||
$associationMapping = $subMetadata->getAssociationMapping($indexProperty);
|
||||
|
||||
/** @var ClassMetadataInfo $subMetadata */
|
||||
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($indexProperty);
|
||||
$subMetadata = $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
|
||||
$typeOfField = $subMetadata->getTypeOfField($indexProperty);
|
||||
}
|
||||
$typeOfField = $subMetadata->getTypeOfField($subMetadata->getFieldForColumn($indexColumn));
|
||||
|
||||
if (!$collectionKeyType = $this->getPhpType($typeOfField)) {
|
||||
return null;
|
||||
|
|
|
@ -42,7 +42,7 @@ class DoctrineDummy
|
|||
public $bar;
|
||||
|
||||
/**
|
||||
* @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid")
|
||||
* @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid_column")
|
||||
*/
|
||||
protected $indexedBar;
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ class DoctrineRelation
|
|||
public $id;
|
||||
|
||||
/**
|
||||
* @Column(type="guid")
|
||||
* @Column(type="guid", name="rguid_column")
|
||||
*/
|
||||
protected $rguid;
|
||||
|
||||
|
|
Reference in New Issue