From 3a282b1e9ca94647766ffb76e44fe70d6a2e7a0f Mon Sep 17 00:00:00 2001 From: romanb Date: Fri, 13 Nov 2009 10:11:14 +0000 Subject: [PATCH] [2.0][DDC-141] Fixed. --- lib/Doctrine/ORM/Query/SqlWalker.php | 4 +-- .../Functional/SingleTableInheritanceTest.php | 25 ++++++++++++++++--- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 862b33e32..27fc2ee2a 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -1115,9 +1115,7 @@ class SqlWalker implements TreeWalker $discrSql = $this->_generateDiscriminatorColumnConditionSql($this->_currentRootAlias); if ($discrSql) { - if ($termsSql) $sql .= ' AND'; - - $sql .= ' ' . $discrSql; + $sql .= ' AND ' . $discrSql; } return $sql; diff --git a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php index 0d5aa156b..b035eea5f 100644 --- a/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php +++ b/tests/Doctrine/Tests/ORM/Functional/SingleTableInheritanceTest.php @@ -22,8 +22,6 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase $this->_em->getClassMetadata('Doctrine\Tests\ORM\Functional\RelatedEntity') )); } catch (\Exception $e) { - var_dump($e->getMessage()); - var_dump($e->getTraceAsString()); // Swallow all exceptions. We do not test the schema tool here. } } @@ -94,7 +92,28 @@ class SingleTableInheritanceTest extends \Doctrine\Tests\OrmFunctionalTestCase $query = $this->_em->createQuery("delete Doctrine\Tests\ORM\Functional\ParentEntity e"); $affected = $query->execute(); - $this->assertEquals(2, $affected); + $this->assertEquals(2, $affected); + + $this->_em->clear(); + + // DQL query with WHERE clause + $child = new ChildEntity; + $child->setData('thedata'); + $child->setNumber(1234); + + $this->_em->persist($child); + $this->_em->flush(); + $this->_em->clear(); + + $query = $this->_em->createQuery('select e from Doctrine\Tests\ORM\Functional\ParentEntity e where e.id=?1'); + $query->setParameter(1, $child->getId()); + + $child2 = $query->getSingleResult(); + $this->assertTrue($child2 instanceof ChildEntity); + $this->assertEquals('thedata', $child2->getData()); + $this->assertEquals(1234, $child2->getNumber()); + $this->assertEquals($child->getId(), $child2->getId()); + $this->assertFalse($child === $child2); } }