Commits

Mike Bayer  committed 64e57ff

- adjust mysql patch a bit so that we use
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]

  • Participants
  • Parent commits 8bdd1a8

Comments (0)

Files changed (3)

     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

File lib/sqlalchemy/dialects/mysql/base.py

                 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
 

File test/dialect/test_mysql.py

                             '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',
             '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')