summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES2
-rw-r--r--lib/sqlalchemy/databases/mysql.py6
2 files changed, 5 insertions, 3 deletions
diff --git a/CHANGES b/CHANGES
index ad4c72f42..4f6fa6e3c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -8,6 +8,8 @@
- postgres no longer uses client-side cursors, uses more efficient server side
cursors via apparently undocumented psycopg2 behavior recently discovered on the
mailing list. disable it via create_engine('postgres://', client_side_cursors=True)
+ - mysql is inconsistent with what kinds of quotes it uses in foreign keys during a
+ SHOW CREATE TABLE, reflection updated to accomodate for all three styles [ticket:420]
- added "fetchmany()" support to ResultProxy
- added "BIGSERIAL" support for postgres table with PGBigInteger/autoincrement
- fixes to postgres reflection to better handle when schema names are present;
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py
index 32402763f..0edcbc7bd 100644
--- a/lib/sqlalchemy/databases/mysql.py
+++ b/lib/sqlalchemy/databases/mysql.py
@@ -422,10 +422,10 @@ class MySQLDialect(ansisql.ANSIDialect):
if match:
tabletype = match.group('ttype')
- fkpat = r'CONSTRAINT `(?P<name>.+?)` FOREIGN KEY \((?P<columns>.+?)\) REFERENCES `(?P<reftable>.+?)` \((?P<refcols>.+?)\)'
+ fkpat = r'''CONSTRAINT [`"'](?P<name>.+?)[`"'] FOREIGN KEY \((?P<columns>.+?)\) REFERENCES [`"'](?P<reftable>.+?)[`"'] \((?P<refcols>.+?)\)'''
for match in re.finditer(fkpat, desc):
- columns = re.findall(r'`(.+?)`', match.group('columns'))
- refcols = [match.group('reftable') + "." + x for x in re.findall(r'`(.+?)`', match.group('refcols'))]
+ columns = re.findall(r'''[`"'](.+?)[`"']''', match.group('columns'))
+ refcols = [match.group('reftable') + "." + x for x in re.findall(r'''[`"'](.+?)[`"']''', match.group('refcols'))]
schema.Table(match.group('reftable'), table.metadata, autoload=True, autoload_with=connection)
constraint = schema.ForeignKeyConstraint(columns, refcols, name=match.group('name'))
table.append_constraint(constraint)