diff options
| -rw-r--r-- | CHANGES | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 6 |
2 files changed, 5 insertions, 3 deletions
@@ -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) |
