diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-08 11:18:39 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-04-08 11:18:39 -0400 |
| commit | 3269b73ff7a12303aadcaed0246d401ec649fa94 (patch) | |
| tree | 4a067222d58144bc39fe2a14523b3baa713d9940 | |
| parent | b7abf86f72e62644846dfd540bcceae7959cd046 (diff) | |
| download | sqlalchemy-3269b73ff7a12303aadcaed0246d401ec649fa94.tar.gz | |
- 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]
| -rw-r--r-- | CHANGES | 7 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 8 | ||||
| -rw-r--r-- | test/dialect/test_mysql.py | 4 |
3 files changed, 15 insertions, 4 deletions
@@ -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 diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 563627136..65c2c59b9 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -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 diff --git a/test/dialect/test_mysql.py b/test/dialect/test_mysql.py index 613fac7c3..9a2e17ecc 100644 --- a/test/dialect/test_mysql.py +++ b/test/dialect/test_mysql.py @@ -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') |
