MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

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

r""" Create an :class:`.ExcludeConstraint` object. E.g.:: const = ExcludeConstraint( (Column("period"), "&&"), (Column("group"), "="), where=(Column("group") != "some group"), ops={"group": "my_operator_cla

(
        self, *elements: Tuple[_DDLColumnArgument, str], **kw: Any
    )

Source from the content-addressed store, hash-verified

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 )
199
200 The exclude constraint defined in this example requires the
201 ``btree_gist`` extension, that can be created using the
202 command ``CREATE EXTENSION btree_gist;``.
203
204 :param \*elements:
205
206 A sequence of two tuples of the form ``(column, operator)`` where
207 "column" is either a :class:`_schema.Column` object, or a SQL
208 expression element (e.g. ``func.int8range(table.from, table.to)``)
209 or the name of a column as string, and "operator" is a string
210 containing the operator to use (e.g. `"&&"` or `"="`).
211
212 In order to specify a column name when a :class:`_schema.Column`
213 object is not available, while ensuring
214 that any necessary quoting rules take effect, an ad-hoc
215 :class:`_schema.Column` or :func:`_expression.column`
216 object should be used.
217 The ``column`` may also be a string SQL expression when
218 passed as :func:`_expression.literal_column` or
219 :func:`_expression.text`
220

Callers

nothing calls this directly

Calls 3

appendMethod · 0.45
__init__Method · 0.45
getMethod · 0.45

Tested by

no test coverage detected