1
0
mirror of synced 2025-02-09 08:49:26 +03:00

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.
This commit is contained in:
Luís Cobucci 2018-02-25 22:35:46 +01:00
parent b952dac339
commit d47c1f3e9b
No known key found for this signature in database
GPG Key ID: EC61C5F01750ED3C

View File

@ -37,6 +37,8 @@ use Doctrine\ORM\Query;
use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\UnitOfWork;
use Doctrine\ORM\Utility\IdentifierFlattener; use Doctrine\ORM\Utility\IdentifierFlattener;
use Doctrine\ORM\Utility\PersisterHelper; 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. * 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']); $targetMapping = $this->em->getClassMetadata($this->class->associationMappings[$idField]['targetEntity']);
$targetType = PersisterHelper::getTypeOfField($targetMapping->identifier[0], $targetMapping, $this->em);
switch (true) { if ($targetType === []) {
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]); throw ORMException::unrecognizedField($targetMapping->identifier[0]);
} }
$types[] = reset($targetType);
} }
if ($versioned) { if ($versioned) {