From a80532a5389fb5d53abc0648ff8e5739fe099826 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Sat, 17 Jan 2015 01:40:56 +0100 Subject: [PATCH] #1178 - correcting association column type when dealing with multiple derived associations/identifier levels Since the ClassMetadata can only know about internal state, any `joinColumn` association details on the inverse side of an association need to be computed by fetching associated metadata. --- .../ORM/Persisters/Entity/BasicEntityPersister.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php index 537961420..8e83ef813 100644 --- a/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/Entity/BasicEntityPersister.php @@ -36,6 +36,7 @@ use Doctrine\ORM\Persisters\SqlValueVisitor; use Doctrine\ORM\Query; use Doctrine\ORM\UnitOfWork; use Doctrine\ORM\Utility\IdentifierFlattener; +use Doctrine\ORM\Utility\PersisterHelper; /** * A BasicEntityPersister maps an entity to a single table in a relational database. @@ -610,15 +611,16 @@ class BasicEntityPersister implements EntityPersister */ protected function prepareUpdateData($entity) { - $result = array(); - $uow = $this->em->getUnitOfWork(); + $versionField = null; + $result = array(); + $uow = $this->em->getUnitOfWork(); if (($versioned = $this->class->isVersioned) != false) { $versionField = $this->class->versionField; } foreach ($uow->getEntityChangeSet($entity) as $field => $change) { - if ($versioned && $versionField == $field) { + if (isset($versionField) && $versionField == $field) { continue; } @@ -668,7 +670,7 @@ class BasicEntityPersister implements EntityPersister $quotedColumn = $this->quoteStrategy->getJoinColumnName($joinColumn, $this->class, $this->platform); $this->quotedColumns[$sourceColumn] = $quotedColumn; - $this->columnTypes[$sourceColumn] = $targetClass->getTypeOfColumn($targetColumn); + $this->columnTypes[$sourceColumn] = PersisterHelper::getTypeOfColumn($targetColumn, $targetClass, $this->em); $result[$owningTable][$sourceColumn] = $newValId ? $newValId[$targetClass->getFieldForColumn($targetColumn)] : null; @@ -1426,7 +1428,7 @@ class BasicEntityPersister implements EntityPersister } if ($this->class->generatorType != ClassMetadata::GENERATOR_TYPE_IDENTITY || $this->class->identifier[0] != $name) { - $columns[] = $this->quoteStrategy->getColumnName($name, $this->class, $this->platform); + $columns[] = $this->quoteStrategy->getColumnName($name, $this->class, $this->platform); $this->columnTypes[$name] = $this->class->fieldMappings[$name]['type']; } }