summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2018-06-28 14:33:14 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2018-06-28 14:34:51 -0400
commit9d2dc7911b7767b97814479d228072b6f566a864 (patch)
treec532a3ff7ccd97bf7aa887ae2c4ca5c0991ad04c /lib/sqlalchemy/dialects
parent6ad882c861403dc7e21ec84eec5f707fe3ffdc7b (diff)
downloadsqlalchemy-9d2dc7911b7767b97814479d228072b6f566a864.tar.gz
Reflect ASC/DESC in MySQL index columns
Fixed bug in index reflection where on MySQL 8.0 an index that includes ASC or DESC in an indexed column specfication would not be correctly reflected, as MySQL 8.0 introduces support for returning this information in a table definition string. Change-Id: I21f64984ade690aac8c87dbe3aad0c1ee8e9727f Fixes: #4293
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/mysql/reflection.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/reflection.py b/lib/sqlalchemy/dialects/mysql/reflection.py
index e15211044..e88bc3f42 100644
--- a/lib/sqlalchemy/dialects/mysql/reflection.py
+++ b/lib/sqlalchemy/dialects/mysql/reflection.py
@@ -76,6 +76,8 @@ class MySQLTableDefinitionParser(object):
if m:
spec = m.groupdict()
# convert columns into name, length pairs
+ # NOTE: we may want to consider SHOW INDEX as the
+ # format of indexes in MySQL becomes more complex
spec['columns'] = self._parse_keyexprs(spec['columns'])
if spec['version_sql']:
m2 = self._re_key_version_sql.match(spec['version_sql'])
@@ -317,11 +319,10 @@ class MySQLTableDefinitionParser(object):
# `col`,`col2`(32),`col3`(15) DESC
#
- # Note: ASC and DESC aren't reflected, so we'll punt...
self._re_keyexprs = _re_compile(
r'(?:'
r'(?:%(iq)s((?:%(esc_fq)s|[^%(fq)s])+)%(fq)s)'
- r'(?:\((\d+)\))?(?=\,|$))+' % quotes)
+ r'(?:\((\d+)\))?(?: +(ASC|DESC))?(?=\,|$))+' % quotes)
# 'foo' or 'foo','bar' or 'fo,o','ba''a''r'
self._re_csv_str = _re_compile(r'\x27(?:\x27\x27|[^\x27])*\x27')