]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Omit metadata kw from Enum repr
authorFederico Caselli <cfederico87@gmail.com>
Thu, 22 Jan 2026 20:05:15 +0000 (21:05 +0100)
committerFederico Caselli <cfederico87@gmail.com>
Tue, 24 Feb 2026 16:32:56 +0000 (16:32 +0000)
Do not render metadata in the repr of enum.

Change-Id: Ic65e9572ff24af8d48e15277cbc824f7c5ce845a
References: #10604

lib/sqlalchemy/sql/sqltypes.py
test/sql/test_types.py

index 98e5783a3d0276a065c4e0181706b4c892df2a19..22fcfb0a697022c9747c5b52ea3119018a226ed2 100644 (file)
@@ -1851,7 +1851,7 @@ class Enum(String, SchemaType, Emulated, TypeEngine[Union[str, enum.Enum]]):
                 ("schema", None),
             ],
             to_inspect=[Enum, SchemaType],
-            omit_kwarg=["schema", "inherit_schema"],
+            omit_kwarg=["schema", "inherit_schema", "metadata"],
         )
 
     def as_generic(self, allow_nulltype=False):
index 17b947f45af1fbc6a69196b834d6ce2a89a58f7c..d68880c3f185be5433bdadb7150a233e2e2afb26 100644 (file)
@@ -2870,6 +2870,12 @@ class EnumTest(AssertsCompiledSQL, fixtures.TablesTest):
             "Enum('x', 'y', length=255)",
         )
 
+    def test_repr_five(self):
+        # this tests that alembic autogenerate renders the enum correctly
+        # without the metadata since that isn't needed.
+        e = Enum("x", "y", length=42, metadata=MetaData(), schema="foo")
+        eq_(repr(e), "Enum('x', 'y', length=42, schema='foo')")
+
     def test_length_native(self):
         e = Enum("x", "y", "long", length=42)
         eq_(e.length, 42)