MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / ExcludeConstraint

Class ExcludeConstraint

lib/sqlalchemy/dialects/postgresql/ext.py:141–327  ·  view source on GitHub ↗

A table-level EXCLUDE constraint. Defines an EXCLUDE constraint as described in the `PostgreSQL documentation`__. __ https://www.postgresql.org/docs/current/static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE

Source from the content-addressed store, hash-verified

139
140
141class ExcludeConstraint(ColumnCollectionConstraint):
142 """A table-level EXCLUDE constraint.
143
144 Defines an EXCLUDE constraint as described in the `PostgreSQL
145 documentation`__.
146
147 __ https://www.postgresql.org/docs/current/static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
148
149 """ # noqa
150
151 __visit_name__ = "exclude_constraint"
152
153 where = None
154 inherit_cache = False
155
156 create_drop_stringify_dialect = "postgresql"
157
158 @elements._document_text_coercion(
159 "where",
160 ":class:`.ExcludeConstraint`",
161 ":paramref:`.ExcludeConstraint.where`",
162 )
163 def __init__(
164 self, *elements: Tuple[_DDLColumnArgument, str], **kw: Any
165 ) -> None:
166 r"""
167 Create an :class:`.ExcludeConstraint` object.
168
169 E.g.::
170
171 const = ExcludeConstraint(
172 (Column("period"), "&&"),
173 (Column("group"), "="),
174 where=(Column("group") != "some group"),
175 ops={"group": "my_operator_class"},
176 )
177
178 The constraint is normally embedded into the :class:`_schema.Table`
179 construct
180 directly, or added later using :meth:`.append_constraint`::
181
182 some_table = Table(
183 "some_table",
184 metadata,
185 Column("id", Integer, primary_key=True),
186 Column("period", TSRANGE()),
187 Column("group", String),
188 )
189
190 some_table.append_constraint(
191 ExcludeConstraint(
192 (some_table.c.period, "&&"),
193 (some_table.c.group, "="),
194 where=some_table.c.group != "some group",
195 name="some_table_excl_const",
196 ops={"group": "my_operator_class"},
197 )
198 )

Calls

no outgoing calls