diff --git a/lib/Doctrine/Common/DataFixtures/Purger/ORMPurger.php b/lib/Doctrine/Common/DataFixtures/Purger/ORMPurger.php index aece53b9..8a0fef2d 100644 --- a/lib/Doctrine/Common/DataFixtures/Purger/ORMPurger.php +++ b/lib/Doctrine/Common/DataFixtures/Purger/ORMPurger.php @@ -19,6 +19,7 @@ namespace Doctrine\Common\DataFixtures\Purger; +use Doctrine\DBAL\Schema\Table; use Doctrine\ORM\EntityManagerInterface; use Doctrine\Common\DataFixtures\Sorter\TopologicalSorter; use Doctrine\ORM\Mapping\ClassMetadata; @@ -244,7 +245,9 @@ private function getTableName($class, $platform) return $class->table['schema'].'.'.$this->em->getConfiguration()->getQuoteStrategy()->getTableName($class, $platform); } - return $this->em->getConfiguration()->getQuoteStrategy()->getTableName($class, $platform); + $tableName = $this->em->getConfiguration()->getQuoteStrategy()->getTableName($class, $platform); + $tableAsset = new Table($tableName); + return $tableAsset->getQuotedName($platform); } /** @@ -262,4 +265,4 @@ private function getJoinTableName($assoc, $class, $platform) return $this->em->getConfiguration()->getQuoteStrategy()->getJoinTableName($assoc, $class, $platform); } -} \ No newline at end of file +} diff --git a/tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerTest.php b/tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerTest.php index 89223656..ccdc7d20 100644 --- a/tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerTest.php +++ b/tests/Doctrine/Tests/Common/DataFixtures/Purger/ORMPurgerTest.php @@ -19,6 +19,7 @@ class ORMPurgerTest extends BaseTest const TEST_ENTITY_USER = 'Doctrine\Tests\Common\DataFixtures\TestEntity\User'; const TEST_ENTITY_USER_WITH_SCHEMA = 'Doctrine\Tests\Common\DataFixtures\TestEntity\UserWithSchema'; const TEST_ENTITY_QUOTED = 'Doctrine\Tests\Common\DataFixtures\TestEntity\Quoted'; + const TEST_ENTITY_RESERVED_KEYWORD = 'Doctrine\Tests\Common\DataFixtures\TestEntity\ReservedKeyword'; public function testGetAssociationTables() @@ -65,4 +66,16 @@ public function testTableNameWithSchema() $this->assertStringStartsWith('test_schema',$tableName); } + public function testTableNameQuotedIfReservedKeyword() + { + $em = $this->getMockAnnotationReaderEntityManager(); + $metadata = $em->getClassMetadata(self::TEST_ENTITY_RESERVED_KEYWORD); + $platform = $em->getConnection()->getDatabasePlatform(); + $purger = new ORMPurger($em); + $class = new ReflectionClass('Doctrine\Common\DataFixtures\Purger\ORMPurger'); + $method = $class->getMethod('getTableName'); + $method->setAccessible(true); + $tableName = $method->invokeArgs($purger, array($metadata, $platform)); + $this->assertEquals($tableName, '"SELECT"'); + } } diff --git a/tests/Doctrine/Tests/Common/DataFixtures/TestEntity/ReservedKeyword.php b/tests/Doctrine/Tests/Common/DataFixtures/TestEntity/ReservedKeyword.php new file mode 100644 index 00000000..7e2896ce --- /dev/null +++ b/tests/Doctrine/Tests/Common/DataFixtures/TestEntity/ReservedKeyword.php @@ -0,0 +1,17 @@ +