From 77b905eaa890bb0915642ef37e4c5eb3b5cfaefb Mon Sep 17 00:00:00 2001 From: John Brown Date: Thu, 6 Jun 2013 15:08:22 -0700 Subject: [PATCH 1/4] Implement QuoteStrategy on SqlWalker walkRangeVariableDeclaration Based on: http://www.doctrine-project.org/jira/browse/DDC-1845 https://github.com/doctrine/doctrine2/commit/cb72219b118c158c9b5344c4b81ff2b1a9149ab0 --- lib/Doctrine/ORM/Query/SqlWalker.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index b971bcfe5c0..9a9ecf58c0a 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -844,8 +844,8 @@ public function walkRangeVariableDeclaration($rangeVariableDeclaration) $this->rootAliases[] = $dqlAlias; - $sql = $class->getQuotedTableName($this->platform) . ' ' - . $this->getSQLTableAlias($class->getTableName(), $dqlAlias); + $sql = $this->quoteStrategy->getTableName($class,$this->platform) . ' ' + . $this->getSQLTableAlias($class->getTableName(), $dqlAlias); if ($class->isInheritanceTypeJoined()) { $sql .= $this->_generateClassTableInheritanceJoins($class, $dqlAlias); From 9bea612d7405c90ac979f41171b0257d2c49d31b Mon Sep 17 00:00:00 2001 From: John Brown Date: Thu, 6 Jun 2013 15:51:23 -0700 Subject: [PATCH 2/4] Adding simple test to ensure quoting of table names still functions. Note: the funtionality of this change won't be noticiable unless a custom quote strategy is implemented --- .../Tests/ORM/Query/SelectSqlGenerationTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php index 26a6a1ec152..1b2c58b8c86 100644 --- a/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php +++ b/tests/Doctrine/Tests/ORM/Query/SelectSqlGenerationTest.php @@ -1831,6 +1831,17 @@ public function testColumnNameWithNumbersAndNonAlphanumericCharacters() ); } + /** + * @group DDC-1845 + */ + public function testQuotedTableDeclaration() + { + $this->assertSqlGeneration( + 'SELECT u FROM Doctrine\Tests\Models\Quote\User u', + 'SELECT q0_."user-id" AS userid0, q0_."user-name" AS username1 FROM "quote-user" q0_' + ); + } + /** * @group DDC-1845 */ From afb9c829e2fb2395924d1064a47a2ac2f64883e0 Mon Sep 17 00:00:00 2001 From: John Brown Date: Fri, 7 Jun 2013 08:49:49 -0700 Subject: [PATCH 3/4] updating sql walker to use quote strategy in joins --- lib/Doctrine/ORM/Query/SqlWalker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 9a9ecf58c0a..820438a593b 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -875,7 +875,7 @@ public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joi $relation = $this->queryComponents[$joinedDqlAlias]['relation']; $targetClass = $this->em->getClassMetadata($relation['targetEntity']); $sourceClass = $this->em->getClassMetadata($relation['sourceEntity']); - $targetTableName = $targetClass->getQuotedTableName($this->platform); + $targetTableName = $this->quoteStrategy->getTableName($targetClass,$this->platform); $targetTableAlias = $this->getSQLTableAlias($targetClass->getTableName(), $joinedDqlAlias); $sourceTableAlias = $this->getSQLTableAlias($sourceClass->getTableName(), $associationPathExpression->identificationVariable); From 4ef043fc3b05f8f610a211d597e802c9c8131c16 Mon Sep 17 00:00:00 2001 From: John Brown Date: Fri, 7 Jun 2013 08:56:58 -0700 Subject: [PATCH 4/4] updating sql walker to use quote strategy in joins --- lib/Doctrine/ORM/Query/SqlWalker.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/ORM/Query/SqlWalker.php b/lib/Doctrine/ORM/Query/SqlWalker.php index 820438a593b..abbb9737423 100644 --- a/lib/Doctrine/ORM/Query/SqlWalker.php +++ b/lib/Doctrine/ORM/Query/SqlWalker.php @@ -930,7 +930,7 @@ public function walkJoinAssociationDeclaration($joinAssociationDeclaration, $joi // Join relation table $joinTable = $assoc['joinTable']; $joinTableAlias = $this->getSQLTableAlias($joinTable['name'], $joinedDqlAlias); - $joinTableName = $sourceClass->getQuotedJoinTableName($assoc, $this->platform); + $joinTableName = $this->quoteStrategy->getJoinTableName($assoc, $sourceClass, $this->platform); $conditions = array(); $relationColumns = ($relation['isOwningSide'])