]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Remove type key in mysql index reflection dicts
authorFederico Caselli <cfederico87@gmail.com>
Fri, 10 Jan 2025 22:26:50 +0000 (23:26 +0100)
committerFederico Caselli <cfederico87@gmail.com>
Fri, 23 May 2025 21:06:41 +0000 (23:06 +0200)
Updated the reflection logic for indexes in the MariaDB and MySQL
dialect to avoid setting the undocumented ``type`` key in the
:class:`_engine.ReflectedIndex` dicts returned by
:class:`_engine.Inspector.get_indexes` method.

Fixes: #12240
Change-Id: Id188d8add441fe2070f36950569401c63ee35ffa

doc/build/changelog/unreleased_21/12240 .rst [new file with mode: 0644]
lib/sqlalchemy/dialects/mysql/base.py

diff --git a/doc/build/changelog/unreleased_21/12240 .rst b/doc/build/changelog/unreleased_21/12240 .rst
new file mode 100644 (file)
index 0000000..e9a6c63
--- /dev/null
@@ -0,0 +1,8 @@
+.. change::
+    :tags: reflection, mysql, mariadb
+    :tickets: 12240 
+
+    Updated the reflection logic for indexes in the MariaDB and MySQL
+    dialect to avoid setting the undocumented ``type`` key in the
+    :class:`_engine.ReflectedIndex` dicts returned by
+    :class:`_engine.Inspector.get_indexes` method.
index ef37ba05652bf632d9a2fb7d6d29bda85779a798..d41c96c590701566a39e16503ce850e8baa8aa63 100644 (file)
@@ -3556,16 +3556,14 @@ class MySQLDialect(default.DefaultDialect):
             if flavor == "UNIQUE":
                 unique = True
             elif flavor in ("FULLTEXT", "SPATIAL"):
-                dialect_options["%s_prefix" % self.name] = flavor
+                dialect_options[f"{self.name}_prefix"] = flavor
             elif flavor is not None:
                 util.warn(
-                    "Converting unknown KEY type %s to a plain KEY", flavor
+                    f"Converting unknown KEY type {flavor} to a plain KEY"
                 )
 
             if spec["parser"]:
-                dialect_options["%s_with_parser" % (self.name)] = spec[
-                    "parser"
-                ]
+                dialect_options[f"{self.name}_with_parser"] = spec["parser"]
 
             index_d: ReflectedIndex = {
                 "name": spec["name"],
@@ -3577,10 +3575,7 @@ class MySQLDialect(default.DefaultDialect):
                 s[0]: s[1] for s in spec["columns"] if s[1] is not None
             }
             if mysql_length:
-                dialect_options["%s_length" % self.name] = mysql_length
-
-            if flavor:
-                index_d["type"] = flavor  # type: ignore[typeddict-unknown-key]
+                dialect_options[f"{self.name}_length"] = mysql_length
 
             if dialect_options:
                 index_d["dialect_options"] = dialect_options