]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- adjust mysql patch a bit so that we use
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 8 Apr 2012 15:18:39 +0000 (11:18 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 8 Apr 2012 15:18:39 +0000 (11:18 -0400)
built in quoting for the "idx_" name as well
- [bug] Fixed bug whereby column name inside
of "KEY" clause for autoincrement composite
column with InnoDB would double quote a
name that's a reserved word.  Courtesy Jeff
Dairiki. [ticket:2460]

CHANGES
lib/sqlalchemy/dialects/mysql/base.py
test/dialect/test_mysql.py

diff --git a/CHANGES b/CHANGES
index c53822455cabb89d780f2fbe8e319229cb312767..a1c5dd4b9b9b0e666c3b5f6ca98a456e016844ea 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -61,6 +61,13 @@ CHANGES
     respectively.  Courtesy Diana Clarke 
     [ticket:2445]
 
+- mysql
+  - [bug] Fixed bug whereby column name inside 
+    of "KEY" clause for autoincrement composite
+    column with InnoDB would double quote a 
+    name that's a reserved word.  Courtesy Jeff
+    Dairiki. [ticket:2460]
+
 0.7.6
 =====
 - orm
index 5636271362306906e965fee1f9b68b77561bf905..65c2c59b9f6c562cfd829f00707d5ee2dba125f5 100644 (file)
@@ -1395,8 +1395,12 @@ class MySQLDDLCompiler(compiler.DDLCompiler):
                 auto_inc_column is not list(table.primary_key)[0]:
             if constraint_string:
                 constraint_string += ", \n\t"
-            constraint_string += "KEY `idx_autoinc_%s`(%s)" % (auto_inc_column.name, \
-                            self.preparer.format_column(auto_inc_column))
+            constraint_string += "KEY %s (%s)" % (
+                        self.preparer.quote(
+                            "idx_autoinc_%s" % auto_inc_column.name, None
+                        ), 
+                        self.preparer.format_column(auto_inc_column)
+                    )
 
         return constraint_string
 
index 613fac7c3299df8cdcfa92e56bb71c691c226ca6..9a2e17ecc1925c931ae5e419b90cc86226d26736 100644 (file)
@@ -1411,7 +1411,7 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL):
                             'CREATE TABLE sometable (assigned_id '
                             'INTEGER NOT NULL, id INTEGER NOT NULL '
                             'AUTO_INCREMENT, PRIMARY KEY (assigned_id, '
-                            'id), KEY `idx_autoinc_id`(id))ENGINE=Inn'
+                            'id), KEY idx_autoinc_id (id))ENGINE=Inn'
                             'oDB')
 
         t1 = Table('sometable', MetaData(), Column('assigned_id',
@@ -1436,7 +1436,7 @@ class SQLTest(fixtures.TestBase, AssertsCompiledSQL):
             'id INTEGER NOT NULL, '
             '`order` INTEGER NOT NULL AUTO_INCREMENT, '
             'PRIMARY KEY (id, `order`), '
-            'KEY `idx_autoinc_order`(`order`)'
+            'KEY idx_autoinc_order (`order`)'
             ')ENGINE=InnoDB')