From: Federico Caselli Date: Fri, 10 Jan 2025 22:26:50 +0000 (+0100) Subject: Remove type key in mysql index reflection dicts X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=45c6e849e608e2b89de4c6d42af2a4e4d3488b7c;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Remove type key in mysql index reflection dicts 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 --- diff --git a/doc/build/changelog/unreleased_21/12240 .rst b/doc/build/changelog/unreleased_21/12240 .rst new file mode 100644 index 0000000000..e9a6c632e2 --- /dev/null +++ b/doc/build/changelog/unreleased_21/12240 .rst @@ -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. diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index ef37ba0565..d41c96c590 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -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