]> 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:12 +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

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 ffe46c9dc7d0879ce3259967c9660d4674d3adc2..bf93e2ceb352c455d8118b06bb598d5c22d2ced8 100644 (file)
@@ -229,6 +229,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'.
@@ -281,6 +286,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 fc460cac18abb2325d45c6bfa86f6083e8425e13..d6ab7c136c1bdba869f1e834c7c39d4ea2970704 100644 (file)
@@ -1262,6 +1262,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))