8000 [DoctrineBridge] indexBy does not refer to attributes, but to column names by xabbuh · Pull Request #38604 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DoctrineBridge] indexBy does not refer to attributes, but to column names #38604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
indexBy does not refer to attributes, but to column names
  • Loading branch information
xabbuh committed Oct 16, 2020
commit af1a6208ec3f2dae1319dea1ac7047aa328d3c2a
13 changes: 2 additions & 11 deletions src/Symfony/Bridge/Doctrine/PropertyInfo/DoctrineExtractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,19 +110,10 @@ public function getTypes($class, $property, array $context = [])
$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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class DoctrineDummy
public $bar;

/**
* @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid")
* @ManyToMany(targetEntity="DoctrineRelation", indexBy="rguid_column")
*/
protected $indexedBar;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class DoctrineRelation
public $id;

/**
* @Column(type="guid")
* @Column(type="guid", name="rguid_column")
*/
protected $rguid;

Expand Down
0