summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/dialects/mysql/base.py2
-rw-r--r--lib/sqlalchemy/dialects/mysql/reflection.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py
index a3e99514b..e8ddb6d1e 100644
--- a/lib/sqlalchemy/dialects/mysql/base.py
+++ b/lib/sqlalchemy/dialects/mysql/base.py
@@ -3162,7 +3162,7 @@ class MySQLDialect(default.DefaultDialect):
sql = self._show_create_table(
connection, None, charset, full_name=full_name
)
- if re.match(r"^CREATE (?:ALGORITHM)?.* VIEW", sql):
+ if parser._check_view(sql):
# Adapt views to something table-like.
columns = self._describe_table(
connection, None, charset, full_name=full_name
diff --git a/lib/sqlalchemy/dialects/mysql/reflection.py b/lib/sqlalchemy/dialects/mysql/reflection.py
index e7a6b157f..44bc62179 100644
--- a/lib/sqlalchemy/dialects/mysql/reflection.py
+++ b/lib/sqlalchemy/dialects/mysql/reflection.py
@@ -74,6 +74,9 @@ class MySQLTableDefinitionParser:
pass
return state
+ def _check_view(self, sql: str) -> bool:
+ return bool(self._re_is_view.match(sql))
+
def _parse_constraints(self, line):
"""Parse a KEY or CONSTRAINT line.
@@ -409,6 +412,8 @@ class MySQLTableDefinitionParser:
self.preparer._unescape_identifier,
)
+ self._re_is_view = _re_compile(r"^CREATE(?! TABLE)(\s.*)?\sVIEW")
+
# `col`,`col2`(32),`col3`(15) DESC
#
self._re_keyexprs = _re_compile(