]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix ExcludeConstraint not forwarding info to parent constructor
authorWiktorB2004 <byrka.w@gmail.com>
Wed, 20 May 2026 20:05:41 +0000 (16:05 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 20 May 2026 20:17:35 +0000 (16:17 -0400)
Fixed issue where the :class:`.ExcludeConstraint` construct did not
correctly forward the :paramref:`.ExcludeConstraint.info` parameter to
the superclass, causing user-defined metadata to be lost. Pull request
courtesy Wiktor Byrka.

Fixes: #13317
Closes: #13316
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13316
Pull-request-sha: be7f4fee2c40d1986519e93145471faad61021af
Change-Id: Idc4846f02127d1d39a8c638cb03b0379932e9fd6
(cherry picked from commit cf2984c31d1f3edcfd26801a8ac560d95b52892e)

doc/build/changelog/unreleased_20/13317.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/ext.py
test/dialect/postgresql/test_compiler.py

diff --git a/doc/build/changelog/unreleased_20/13317.rst b/doc/build/changelog/unreleased_20/13317.rst
new file mode 100644 (file)
index 0000000..8000af1
--- /dev/null
@@ -0,0 +1,9 @@
+.. change::
+    :tags: bug, postgresql
+    :tickets: 13317
+
+    Fixed issue where the :class:`.ExcludeConstraint` construct did not
+    correctly forward the :paramref:`.ExcludeConstraint.info` parameter to
+    the superclass, causing user-defined metadata to be lost. Pull request
+    courtesy Wiktor Byrka.
+
index 651f40f91aae4ff3b572a84534995b3005b98c44..55bfebb035e1b4bb3b8e50f0aed1c60e2e92d26e 100644 (file)
@@ -234,6 +234,11 @@ class ExcludeConstraint(ColumnCollectionConstraint):
           Optional string.  If set, emit INITIALLY <value> when issuing DDL
           for this constraint.
 
+        :param info: Optional data dictionary which will be populated into the
+            :attr:`.SchemaItem.info` attribute of this object.
+
+            .. versionadded:: 2.0.50
+
         :param using:
           Optional string.  If set, emit USING <index_method> when issuing DDL
           for this constraint. Defaults to 'gist'.
@@ -288,6 +293,7 @@ class ExcludeConstraint(ColumnCollectionConstraint):
             name=kw.get("name"),
             deferrable=kw.get("deferrable"),
             initially=kw.get("initially"),
+            info=kw.get("info"),
         )
         self.using = kw.get("using", "gist")
         where = kw.get("where")
index 38eda0cfd2affbfa6d48e704eab819c3a81b9e31..d53db137217e70ba2e73f040781d674dbdbc7ec4 100644 (file)
@@ -1221,6 +1221,13 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL):
             ")",
         )
 
+    def test_exclude_constraint_info(self):
+        ec = ExcludeConstraint(("a", "="))
+        eq_(ec.info, {})
+
+        ec = ExcludeConstraint(("a", "="), info={"foo": "bar"})
+        eq_(ec.info, {"foo": "bar"})
+
     def test_exclude_constraint_min(self):
         m = MetaData()
         tbl = Table("testtbl", m, Column("room", Integer, primary_key=True))