From bd70cdb5fd9971f4989f8ebbad6fea2b4fc4462a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 12 Jan 2007 01:57:41 +0000 Subject: - 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] --- lib/sqlalchemy/databases/mysql.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/sqlalchemy/databases/mysql.py') 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.+?)` FOREIGN KEY \((?P.+?)\) REFERENCES `(?P.+?)` \((?P.+?)\)' + fkpat = r'''CONSTRAINT [`"'](?P.+?)[`"'] FOREIGN KEY \((?P.+?)\) REFERENCES [`"'](?P.+?)[`"'] \((?P.+?)\)''' 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) -- cgit v1.2.1