From: Mike Bayer Date: Fri, 12 Jan 2007 01:57:41 +0000 (+0000) Subject: - mysql is inconsistent with what kinds of quotes it uses in foreign keys during a X-Git-Tag: rel_0_3_4~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd70cdb5fd9971f4989f8ebbad6fea2b4fc4462a;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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] --- diff --git a/CHANGES b/CHANGES index ad4c72f422..4f6fa6e3ca 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 32402763fe..0edcbc7bd0 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)