]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Type postgresql.ExcludeConstraint()
authorDenis Laxalde <denis@laxalde.org>
Mon, 1 Dec 2025 10:43:18 +0000 (05:43 -0500)
committerFederico Caselli <cfederico87@gmail.com>
Tue, 2 Dec 2025 19:12:31 +0000 (20:12 +0100)
Related to #6810.

Closes: #13011
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/13011
Pull-request-sha: 4a212cad1b231629ae4e3d6866c9603662a197a2

Change-Id: If5d91e06b6c0afc11adc02bb0c0d5ce97e53203c
(cherry picked from commit 4f87f4d9265adf826bd10b3b764405c3b871b5d8)

lib/sqlalchemy/dialects/postgresql/ext.py
test/typing/plain_files/dialects/postgresql/pg_stuff.py

index 54bacd9447158a8eb474db84411c6fab9ef16edc..8d24b107ad443322f96f3622e2d7abfb00af67f2 100644 (file)
@@ -12,6 +12,7 @@ from typing import Iterable
 from typing import List
 from typing import Optional
 from typing import overload
+from typing import Tuple
 from typing import TYPE_CHECKING
 from typing import TypeVar
 
@@ -29,6 +30,7 @@ from ...sql.visitors import InternalTraversal
 
 if TYPE_CHECKING:
     from ...sql._typing import _ColumnExpressionArgument
+    from ...sql._typing import _DDLColumnArgument
     from ...sql.elements import ClauseElement
     from ...sql.elements import ColumnElement
     from ...sql.operators import OperatorType
@@ -163,7 +165,9 @@ class ExcludeConstraint(ColumnCollectionConstraint):
         ":class:`.ExcludeConstraint`",
         ":paramref:`.ExcludeConstraint.where`",
     )
-    def __init__(self, *elements, **kw):
+    def __init__(
+        self, *elements: Tuple[_DDLColumnArgument, str], **kw: Any
+    ) -> None:
         r"""
         Create an :class:`.ExcludeConstraint` object.
 
index 9669cc7d77b4765ab5bcb021f05eb2e25563c68d..265af688a368cd70daefb0c91d781f1a28b4ccbd 100644 (file)
@@ -14,6 +14,7 @@ from sqlalchemy.dialects.postgresql import aggregate_order_by
 from sqlalchemy.dialects.postgresql import ARRAY
 from sqlalchemy.dialects.postgresql import array
 from sqlalchemy.dialects.postgresql import DATERANGE
+from sqlalchemy.dialects.postgresql import ExcludeConstraint
 from sqlalchemy.dialects.postgresql import insert
 from sqlalchemy.dialects.postgresql import INT4RANGE
 from sqlalchemy.dialects.postgresql import INT8MULTIRANGE
@@ -51,6 +52,8 @@ class Test(Base):
 
     ident_str: Mapped[str] = mapped_column(UUID(as_uuid=False))
 
+    __table_args__ = (ExcludeConstraint((Column("ident_str"), "=")),)
+
 
 elem = func.jsonb_array_elements(Test.data, type_=JSONB).column_valued("elem")