Made a small adjustment in the table reflection feature of the MySQL
dialect to accommodate for alternate MySQL-oriented databases such as TiDB
which include their own "comment" directives at the end of a constraint
directive within "CREATE TABLE" where the format doesn't have the
additional space character after the comment, in this case the TiDB
"clustered index" feature. Pull request courtesy Daniël van Eeden.
Fixes: #6659
Closes: #6660
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/6660
Pull-request-sha:
98791a441b2e3d26aa7cef9d3e2907fac113e30f
Change-Id: I20d206e0cdb809e4c6997b87159edf41249f7cd9
--- /dev/null
+.. change::
+ :tags: usecase, mysql
+ :tickets: 6659
+
+ Made a small adjustment in the table reflection feature of the MySQL
+ dialect to accommodate for alternate MySQL-oriented databases such as TiDB
+ which include their own "comment" directives at the end of a constraint
+ directive within "CREATE TABLE" where the format doesn't have the
+ additional space character after the comment, in this case the TiDB
+ "clustered index" feature. Pull request courtesy Daniël van Eeden.
r"(?: +KEY_BLOCK_SIZE *[ =]? *(?P<keyblock>\S+))?"
r"(?: +WITH PARSER +(?P<parser>\S+))?"
r"(?: +COMMENT +(?P<comment>(\x27\x27|\x27([^\x27])*?\x27)+))?"
- r"(?: +/\*(?P<version_sql>.+)\*/ +)?"
+ r"(?: +/\*(?P<version_sql>.+)\*/ *)?"
r",?$" % quotes
)
assert not regex.match(
" PRIMARY KEY (`id`) USING BTREE KEY_BLOCK_SIZE = = 16"
)
+ # test #6659 (TiDB)
+ assert regex.match(
+ " PRIMARY KEY (`id`) /*T![clustered_index] CLUSTERED */"
+ )
assert regex.match(" KEY (`id`) USING BTREE COMMENT 'comment'")
# `SHOW CREATE TABLE` returns COMMENT '''comment'
# after creating table with COMMENT '\'comment'
"/*!50100 WITH PARSER `ngram` */ "
)
+ m = regex.match(" PRIMARY KEY (`id`)")
+ eq_(m.group("type"), "PRIMARY")
+ eq_(m.group("columns"), "`id`")
+
def test_key_reflection_columns(self):
regex = self.parser._re_key
exprs = self.parser._re_keyexprs