]> 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)
committersqla-tester <sqla-tester@sqlalchemy.org>
Mon, 1 Dec 2025 10:43:18 +0000 (05:43 -0500)
Related to #6810.

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

Change-Id: If5d91e06b6c0afc11adc02bb0c0d5ce97e53203c

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

index d251c11d6c067e09b38f3794479774d2c7bd7e6a..a33bfd76f5e432bcc7298ff4d4297aa40aa6ebe3 100644 (file)
@@ -13,6 +13,7 @@ from typing import List
 from typing import Optional
 from typing import overload
 from typing import Sequence
+from typing import Tuple
 from typing import TYPE_CHECKING
 from typing import TypeVar
 
@@ -32,6 +33,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
@@ -158,7 +160,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 ec99ec1b0c5e4b3af6ccf5c41e8d1b4520d1adf9..14992511037485c1d1ab35c125d815c1d4aa313d 100644 (file)
@@ -19,6 +19,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
@@ -55,6 +56,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")