From 76663a050166bcee7596f26447be5eec532694f5 Mon Sep 17 00:00:00 2001 From: romanb Date: Thu, 18 Mar 2010 11:40:43 +0000 Subject: [PATCH] [2.0][DDC-416] Fixed. --- lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php | 6 +++++- .../Tests/ORM/Functional/ClassTableInheritanceTest.php | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php b/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php index 728a5a9f2..a1424d113 100644 --- a/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php +++ b/lib/Doctrine/ORM/Persisters/JoinedSubclassPersister.php @@ -398,7 +398,11 @@ class JoinedSubclassPersister extends StandardEntityPersister $conditionSql = ''; foreach ($criteria as $field => $value) { if ($conditionSql != '') $conditionSql .= ' AND '; - $conditionSql .= $baseTableAlias . '.'; + if (isset($this->_class->fieldMappings[$field]['inherited'])) { + $conditionSql .= $this->_getSQLTableAlias($this->_em->getClassMetadata($this->_class->fieldMappings[$field]['inherited'])) . '.'; + } else { + $conditionSql .= $baseTableAlias . '.'; + } if (isset($this->_class->columnNames[$field])) { $conditionSql .= $this->_class->getQuotedColumnName($field, $this->_platform); } else if ($assoc !== null) { diff --git a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php index 1ad7409dd..eb607b93c 100644 --- a/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/ClassTableInheritanceTest.php @@ -71,6 +71,12 @@ class ClassTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->clear(); + $guilherme = $this->_em->getRepository(get_class($employee))->findOneBy(array('name' => 'Guilherme Blanco')); + $this->assertTrue($guilherme instanceof CompanyEmployee); + $this->assertEquals('Guilherme Blanco', $guilherme->getName()); + + $this->_em->clear(); + $query = $this->_em->createQuery("update Doctrine\Tests\Models\Company\CompanyEmployee p set p.name = ?1, p.department = ?2 where p.name='Guilherme Blanco' and p.salary = ?3"); $query->setParameter(1, 'NewName'); $query->setParameter(2, 'NewDepartment');