summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2017-01-17 10:47:33 -0500
committerGerrit Code Review <gerrit@awstats.zzzcomputing.com>2017-01-17 10:47:33 -0500
commit99d65925e6aebaea25a0a9f2fc7fa0217974fa7f (patch)
treecb48adc92e1700cda07b66ad240e57597d4595cd
parent1f407c2a47150ddd550d3167015a9315e018d7bc (diff)
parentbd6ba3ac8274381e578c8e6c8018a7878fe94208 (diff)
downloadsqlalchemy-99d65925e6aebaea25a0a9f2fc7fa0217974fa7f.tar.gz
Merge "Parse (but don't record) COMMENT portion of MySQL table key"
-rw-r--r--doc/build/changelog/changelog_11.rst9
-rw-r--r--lib/sqlalchemy/dialects/mysql/reflection.py1
-rw-r--r--test/dialect/mysql/test_reflection.py12
3 files changed, 22 insertions, 0 deletions
diff --git a/doc/build/changelog/changelog_11.rst b/doc/build/changelog/changelog_11.rst
index 31df8720f..619eb00ab 100644
--- a/doc/build/changelog/changelog_11.rst
+++ b/doc/build/changelog/changelog_11.rst
@@ -146,6 +146,15 @@
:class:`.Engine`, concealing the URL password. Pull request courtesy
Valery Yundin.
+ .. change:: 3867
+ :tags: bug, mysql
+ :tickets: 3867
+
+ The MySQL dialect now will not warn when a reflected column has a
+ "COMMENT" keyword on it, but note however the comment is not yet
+ reflected; this is on the roadmap for a future release. Pull request
+ courtesy Lele Long.
+
.. change:: pg_timestamp_zero_prec
:tags: bug, postgresql
diff --git a/lib/sqlalchemy/dialects/mysql/reflection.py b/lib/sqlalchemy/dialects/mysql/reflection.py
index d020fb296..f5f09b80b 100644
--- a/lib/sqlalchemy/dialects/mysql/reflection.py
+++ b/lib/sqlalchemy/dialects/mysql/reflection.py
@@ -359,6 +359,7 @@ class MySQLTableDefinitionParser(object):
r'(?: +USING +(?P<using_post>\S+))?'
r'(?: +KEY_BLOCK_SIZE *[ =]? *(?P<keyblock>\S+))?'
r'(?: +WITH PARSER +(?P<parser>\S+))?'
+ r'(?: +COMMENT +(?P<comment>(\x27\x27|\x27([^\x27])*?\x27)+))?'
r',?$'
% quotes
)
diff --git a/test/dialect/mysql/test_reflection.py b/test/dialect/mysql/test_reflection.py
index ddf158167..2ccb299bc 100644
--- a/test/dialect/mysql/test_reflection.py
+++ b/test/dialect/mysql/test_reflection.py
@@ -552,6 +552,18 @@ class RawReflectionTest(fixtures.TestBase):
' PRIMARY KEY (`id`) USING BTREE KEY_BLOCK_SIZE = 16')
assert not regex.match(
' PRIMARY KEY (`id`) USING BTREE KEY_BLOCK_SIZE = = 16')
+ assert regex.match(
+ " KEY (`id`) USING BTREE COMMENT 'comment'")
+ # `SHOW CREATE TABLE` returns COMMENT '''comment'
+ # after creating table with COMMENT '\'comment'
+ assert regex.match(
+ " KEY (`id`) USING BTREE COMMENT '''comment'")
+ assert regex.match(
+ " KEY (`id`) USING BTREE COMMENT 'comment'''")
+ assert regex.match(
+ " KEY (`id`) USING BTREE COMMENT 'prefix''suffix'")
+ assert regex.match(
+ " KEY (`id`) USING BTREE COMMENT 'prefix''text''suffix'")
def test_fk_reflection(self):
regex = self.parser._re_constraint