]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
Fixes: #1300 (inability to pass an ExcludeConstraint object to DropConstraintOp.from_...
authord3 <david.hills@florincourt.com>
Wed, 23 Aug 2023 13:14:54 +0000 (14:14 +0100)
committerd3 <david.hills@florincourt.com>
Wed, 23 Aug 2023 13:18:10 +0000 (14:18 +0100)
alembic/operations/ops.py
tests/test_postgresql.py

index 4066ac7ec22524628b99e68b51053b0523501351..2bd4a094e275e8ec587544bea4ff1d4427087ce2 100644 (file)
@@ -164,6 +164,7 @@ class DropConstraintOp(MigrateOperation):
             "check_constraint": "check",
             "column_check_constraint": "check",
             "table_or_column_check_constraint": "check",
+            "exclude_constraint": "exclude",
         }
 
         constraint_table = sqla_compat._table_for_constraint(constraint)
index a91d7f9429b94b2240063aba9f18a9616fe3fb9c..af278dab39617b1e39e471da956aa47594174f9f 100644 (file)
@@ -1258,6 +1258,30 @@ class PostgresqlAutogenRenderTest(TestBase):
             "name='TExclID'))",
         )
 
+    def test_drop_exclude_constraint(self):
+        """test for #1300"""
+
+        autogen_context = self.autogen_context
+
+        m = MetaData()
+        t = Table(
+            "TTable", m, Column("XColumn", String), Column("YColumn", String)
+        )
+
+        op_obj = ops.DropConstraintOp.from_constraint(
+            ExcludeConstraint(
+                (t.c.XColumn, ">"),
+                where=t.c.XColumn != 2,
+                using="gist",
+                name="t_excl_x",
+            )
+        )
+
+        eq_ignore_whitespace(
+            autogenerate.render_op_text(autogen_context, op_obj),
+            "op.drop_constraint('t_excl_x', 'TTable',  type_='exclude')",
+        )
+
     def test_json_type(self):
         eq_ignore_whitespace(
             autogenerate.render._repr_type(JSON(), self.autogen_context),