From d47c1f3e9b3c6a9b6df8de760fbfb7a33f13d2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Cobucci?= Date: Sun, 25 Feb 2018 22:35:46 +0100 Subject: [PATCH] Fix basic entity persister type resolver Which was using the wrong way to fetch the field type and using the association type instead of the column type. --- .../Persisters/Entity/BasicEntityPersister.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 2797a76e9..14344d9f6 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -37,6 +37,8 @@ use Doctrine\ORM\Query; use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\Utility\IdentifierFlattener; use Doctrine\ORM\Utility\PersisterHelper; +use function array_merge; +use function reset; /** * A BasicEntityPersister maps an entity to a single table in a relational database. @@ -459,20 +461,13 @@ class BasicEntityPersister implements EntityPersister ); $targetMapping = $this->em->getClassMetadata($this->class->associationMappings[$idField]['targetEntity']); + $targetType = PersisterHelper::getTypeOfField($targetMapping->identifier[0], $targetMapping, $this->em); - switch (true) { - case (isset($targetMapping->fieldMappings[$targetMapping->identifier[0]])): - $types[] = $targetMapping->fieldMappings[$targetMapping->identifier[0]]['type']; - break; - - case (isset($targetMapping->associationMappings[$targetMapping->identifier[0]])): - $types[] = $targetMapping->associationMappings[$targetMapping->identifier[0]]['type']; - break; - - default: - throw ORMException::unrecognizedField($targetMapping->identifier[0]); + if ($targetType === []) { + throw ORMException::unrecognizedField($targetMapping->identifier[0]); } + $types[] = reset($targetType); } if ($versioned) {