MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

lib/sqlalchemy/dialects/postgresql/ext.py:168–303  ·  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

166 ":paramref:`.ExcludeConstraint.where`",
167 )
168 def __init__(
169 self, *elements: Tuple[_DDLColumnArgument, str], **kw: Any
170 ) -> None:
171 r"""
172 Create an :class:`.ExcludeConstraint` object.
173
174 E.g.::
175
176 const = ExcludeConstraint(
177 (Column("period"), "&&"),
178 (Column("group"), "="),
179 where=(Column("group") != "some group"),
180 ops={"group": "my_operator_class"},
181 )
182
183 The constraint is normally embedded into the :class:`_schema.Table`
184 construct
185 directly, or added later using :meth:`.append_constraint`::
186
187 some_table = Table(
188 "some_table",
189 metadata,
190 Column("id", Integer, primary_key=True),
191 Column("period", TSRANGE()),
192 Column("group", String),
193 )
194
195 some_table.append_constraint(
196 ExcludeConstraint(
197 (some_table.c.period, "&&"),
198 (some_table.c.group, "="),
199 where=some_table.c.group != "some group",
200 name="some_table_excl_const",
201 ops={"group": "my_operator_class"},
202 )
203 )
204
205 The exclude constraint defined in this example requires the
206 ``btree_gist`` extension, that can be created using the
207 command ``CREATE EXTENSION btree_gist;``.
208
209 :param \*elements:
210
211 A sequence of two tuples of the form ``(column, operator)`` where
212 "column" is either a :class:`_schema.Column` object, or a SQL
213 expression element (e.g. ``func.int8range(table.from, table.to)``)
214 or the name of a column as string, and "operator" is a string
215 containing the operator to use (e.g. `"&&"` or `"="`).
216
217 In order to specify a column name when a :class:`_schema.Column`
218 object is not available, while ensuring
219 that any necessary quoting rules take effect, an ad-hoc
220 :class:`_schema.Column` or :func:`_expression.column`
221 object should be used.
222 The ``column`` may also be a string SQL expression when
223 passed as :func:`_expression.literal_column` or
224 :func:`_expression.text`
225

Callers

nothing calls this directly

Calls 3

appendMethod · 0.45
__init__Method · 0.45
getMethod · 0.45

Tested by

no test coverage detected