From 1f665e6ba8fbf67608dae82e8f35aab76129d2c3 Mon Sep 17 00:00:00 2001
From: Benjamin Eberlei <kontakt@beberlei.de>
Date: Sat, 30 Apr 2011 16:20:14 +0200
Subject: [PATCH] [DBAL-115] Bugfix in SchemaTool not quoting table names when
 dropping schema.

---
 lib/Doctrine/ORM/Tools/SchemaTool.php | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/Doctrine/ORM/Tools/SchemaTool.php b/lib/Doctrine/ORM/Tools/SchemaTool.php
index ffeb15859..b52c584a4 100644
--- a/lib/Doctrine/ORM/Tools/SchemaTool.php
+++ b/lib/Doctrine/ORM/Tools/SchemaTool.php
@@ -617,9 +617,10 @@ class SchemaTool
         $associationTables = $this->_getAssociationTables($commitOrder);
 
         // Drop association tables first
-        foreach ($associationTables as $associationTable) {
-            if (!in_array($associationTable, $orderedTables)) {
-                $orderedTables[] = $associationTable;
+        foreach ($associationTables as $quotedAssociationTableName) {
+            // avoid adding duplicates
+            if (!in_array($quotedAssociationTableName, $orderedTables)) {
+                $orderedTables[] = $quotedAssociationTableName;
             }
         }
 
@@ -633,7 +634,7 @@ class SchemaTool
             }
 
             if (!in_array($class->getTableName(), $orderedTables)) {
-                $orderedTables[] = $class->getTableName();
+                $orderedTables[] = $class->getQuotedTableName($this->_platform);
             }
         }
 
@@ -731,9 +732,10 @@ class SchemaTool
         $associationTables = array();
 
         foreach ($classes as $class) {
+            /* @var $class \Doctrine\ORM\Mapping\ClassMetadata */
             foreach ($class->associationMappings as $assoc) {
                 if ($assoc['isOwningSide'] && $assoc['type'] == ClassMetadata::MANY_TO_MANY) {
-                    $associationTables[] = $assoc['joinTable']['name'];
+                    $associationTables[] = $class->getQuotedJoinTableName($assoc, $this->_platform);
                 }
             }
         }