Skip to content

Commit

Permalink
More generic fix for complex join columns
Browse files Browse the repository at this point in the history
  • Loading branch information
michnovka committed Dec 6, 2022
1 parent 20d6c53 commit 114beb9
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/Doctrine/ORM/UnitOfWork.php
Original file line number Diff line number Diff line change
Expand Up @@ -2812,10 +2812,6 @@ public function createEntity($className, array $data, &$hints = [])
$joinColumnValue = $data[$srcColumn] ?? null;

if ($joinColumnValue !== null) {
if ($joinColumnValue instanceof BackedEnum) {
$joinColumnValue = $joinColumnValue->value;
}

if ($targetClass->containsForeignIdentifier) {
$associatedId[$targetClass->getFieldForColumn($targetColumn)] = $joinColumnValue;
} else {
Expand Down Expand Up @@ -2847,7 +2843,8 @@ public function createEntity($className, array $data, &$hints = [])
// Check identity map first
// FIXME: Can break easily with composite keys if join column values are in
// wrong order. The correct order is the one in ClassMetadata#identifier.
$relatedIdHash = implode(' ', $associatedId);
$associatedIdFlattened = $this->identifierFlattener->flattenIdentifier($targetClass, $associatedId);
$relatedIdHash = implode(' ', $associatedIdFlattened);

switch (true) {
case isset($this->identityMap[$targetClass->rootEntityName][$relatedIdHash]):
Expand Down

0 comments on commit 114beb9

Please sign in to comment.