Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DoctrineBridge] Take into account that indexBy="person_id" could be a db column name, for a referenced entity #39667

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
Jan 15, 2021
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
[DoctrineBridge] Take into account that indexBy="person_id" could be …
…a db column name, for a referenced entity
  • Loading branch information
victormacko authored and xabbuh committed Jan 15, 2021
commit 472eab11e9a9bafc5510d6b02b7c22d6cb525c50
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,12 @@ public function getTypes($class, $property, array $context = [])
/** @var ClassMetadataInfo $subMetadata */
$indexProperty = $subMetadata->getSingleAssociationReferencedJoinColumnName($fieldName);
$subMetadata = $this->entityManager ? $this->entityManager->getClassMetadata($associationMapping['targetEntity']) : $this->classMetadataFactory->getMetadataFor($associationMapping['targetEntity']);
$typeOfField = $subMetadata->getTypeOfField($indexProperty);

//Not a property, maybe a column name?
jderusse marked this conversation as resolved.
Show resolved Hide resolved
if (null === ($typeOfField = $subMetadata->getTypeOfField($indexProperty))) {
nicolas-grekas marked this conversation as resolved.
Show resolved Hide resolved
$fieldName = $subMetadata->getFieldForColumn($indexProperty);
$typeOfField = $subMetadata->getTypeOfField($fieldName);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private function doTestGetProperties(bool $legacy)
'indexedByDt',
'indexedByCustomType',
'indexedBuz',
'dummyGeneratedValueList',
]);

$this->assertEquals(
Expand Down Expand Up @@ -245,6 +246,15 @@ public function typesProvider()
new Type(Type::BUILTIN_TYPE_STRING),
new Type(Type::BUILTIN_TYPE_OBJECT, false, DoctrineRelation::class)
)]],
['dummyGeneratedValueList', [new Type(
Type::BUILTIN_TYPE_OBJECT,
false,
'Doctrine\Common\Collections\Collection',
true,
new Type(Type::BUILTIN_TYPE_INT),
new Type(Type::BUILTIN_TYPE_OBJECT, false, DoctrineRelation::class)
)]],
['json', null],
];

if (class_exists(Types::class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,9 @@ class DoctrineDummy
* @OneToMany(targetEntity="DoctrineRelation", mappedBy="buzField", indexBy="buzField")
*/
protected $indexedBuz;

/**
* @OneToMany(targetEntity="DoctrineRelation", mappedBy="dummyRelation", indexBy="gen_value_col_id", orphanRemoval=true)
*/
protected $dummyGeneratedValueList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\OneToMany;

/**
* @author Kévin Dunglas <dunglas@gmail.com>
Expand All @@ -34,4 +35,15 @@ class DoctrineGeneratedValue
* @Column
*/
public $foo;

/**
* @var int
* @Column(type="integer", name="gen_value_col_id")
*/
public $valueId;

/**
* @OneToMany(targetEntity="DoctrineRelation", mappedBy="generatedValueRelation", indexBy="rguid_column", orphanRemoval=true)
*/
protected $relationList;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\JoinColumn;

/**
* @Entity
Expand Down Expand Up @@ -60,4 +61,15 @@ class DoctrineRelation
* @ManyToOne(targetEntity="DoctrineDummy", inversedBy="indexedBuz")
*/
protected $buzField;

/**
* @ManyToOne(targetEntity="DoctrineDummy", inversedBy="dummyGeneratedValueList")
*/
private $dummyRelation;

/**
* @ManyToOne(targetEntity="DoctrineGeneratedValue", inversedBy="relationList")
* @JoinColumn(name="gen_value_col_id", referencedColumnName="gen_value_col_id")
*/
private $generatedValueRelation;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.