]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- mysql is inconsistent with what kinds of quotes it uses in foreign keys during a
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 12 Jan 2007 01:57:41 +0000 (01:57 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 12 Jan 2007 01:57:41 +0000 (01:57 +0000)
  SHOW CREATE TABLE, reflection updated to accomodate for all three styles [ticket:420]

CHANGES
lib/sqlalchemy/databases/mysql.py

diff --git a/CHANGES b/CHANGES
index ad4c72f422fab7d4fbaf38ef52d6cb373f06cf99..4f6fa6e3cace7ec1c9be1d787e47a7dd38eb8015 100644 (file)
--- 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;
index 32402763fe693fd9e89dae07fcd29dca6a2bd381..0edcbc7bd03764cdc8d61adf00a9eecb74c9de80 100644 (file)
@@ -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)