From 5bf169202fd30bcbbb5a1183091f707846528fd0 Mon Sep 17 00:00:00 2001 From: beberlei Date: Fri, 26 Feb 2010 20:29:01 +0000 Subject: [PATCH] [2.0] DDC-370 - Fixed bug with CTI and scalar fields DDC-377 - Fixed failing Oracle test --- lib/Doctrine/ORM/Query/SqlWalker.php | 8 +++++++- .../Tests/ORM/Functional/AdvancedDqlQueryTest.php | 13 +++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 118037c07..5a2501481 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -815,8 +815,14 @@ class SqlWalker implements TreeWalker } else { $resultAlias = $selectExpression->fieldIdentificationVariable; } + + if ($class->isInheritanceTypeJoined()) { + $tableName = $this->_em->getUnitOfWork()->getEntityPersister($class->name)->getOwningTable($fieldName); + } else { + $tableName = $class->getTableName(); + } - $sqlTableAlias = $this->getSqlTableAlias($class->getTableName(), $dqlAlias); + $sqlTableAlias = $this->getSqlTableAlias($tableName, $dqlAlias); $columnName = $class->getQuotedColumnName($fieldName, $this->_platform); $columnAlias = $this->getSqlColumnAlias($columnName); diff --git a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php index 28096f3d5..a00ac185f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/AdvancedDqlQueryTest.php @@ -28,7 +28,7 @@ class AdvancedDqlQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase { $dql = 'SELECT p.department, AVG(p.salary) AS avgSalary '. 'FROM Doctrine\Tests\Models\Company\CompanyEmployee p '. - 'GROUP BY p.department HAVING SUM(p.salary) > 200000'; + 'GROUP BY p.department HAVING SUM(p.salary) > 200000 ORDER BY p.department'; $result = $this->_em->createQuery($dql)->getScalarResult(); @@ -97,22 +97,23 @@ class AdvancedDqlQueryTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->assertEquals('Roman B.', $result[0]['name']); } - /*public function testGroupByMultipleFields() + public function testGroupByMultipleFields() { $dql = 'SELECT p.department, p.name, count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p '. 'GROUP BY p.department, p.name'; $result = $this->_em->createQuery($dql)->getResult(); - }*/ - /** + $this->assertEquals(4, count($result)); + } + public function testUpdateAs() { $dql = 'UPDATE Doctrine\Tests\Models\Company\CompanyEmployee AS p SET p.salary = 1'; $this->_em->createQuery($dql)->getResult(); $this->assertTrue(count($this->_em->createQuery( - 'SELECT count(p) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1')->getResult()) > 0); - }*/ + 'SELECT count(p.id) FROM Doctrine\Tests\Models\Company\CompanyEmployee p WHERE p.salary = 1')->getResult()) > 0); + } /*public function testDeleteAs() {