r"""Construct a CHECK constraint. :param sqltext: A string containing the constraint definition, which will be used verbatim, or a SQL expression construct. If given as a string, the object is converted to a :func:`_expression.text` object. If the textu
(
self,
sqltext: _TextCoercedExpressionArgument[Any],
name: _ConstraintNameArgument = None,
deferrable: Optional[bool] = None,
initially: Optional[str] = None,
table: Optional[Table] = None,
info: Optional[_InfoType] = None,
_create_rule: Optional[Any] = None,
_autoattach: bool = True,
_type_bound: bool = False,
**dialect_kw: Any,
)
| 4488 | ":paramref:`.CheckConstraint.sqltext`", |
| 4489 | ) |
| 4490 | def __init__( |
| 4491 | self, |
| 4492 | sqltext: _TextCoercedExpressionArgument[Any], |
| 4493 | name: _ConstraintNameArgument = None, |
| 4494 | deferrable: Optional[bool] = None, |
| 4495 | initially: Optional[str] = None, |
| 4496 | table: Optional[Table] = None, |
| 4497 | info: Optional[_InfoType] = None, |
| 4498 | _create_rule: Optional[Any] = None, |
| 4499 | _autoattach: bool = True, |
| 4500 | _type_bound: bool = False, |
| 4501 | **dialect_kw: Any, |
| 4502 | ) -> None: |
| 4503 | r"""Construct a CHECK constraint. |
| 4504 | |
| 4505 | :param sqltext: |
| 4506 | A string containing the constraint definition, which will be used |
| 4507 | verbatim, or a SQL expression construct. If given as a string, |
| 4508 | the object is converted to a :func:`_expression.text` object. |
| 4509 | If the textual |
| 4510 | string includes a colon character, escape this using a backslash:: |
| 4511 | |
| 4512 | CheckConstraint(r"foo ~ E'a(?\:b|c)d") |
| 4513 | |
| 4514 | :param name: |
| 4515 | Optional, the in-database name of the constraint. |
| 4516 | |
| 4517 | :param deferrable: |
| 4518 | Optional bool. If set, emit DEFERRABLE or NOT DEFERRABLE when |
| 4519 | issuing DDL for this constraint. |
| 4520 | |
| 4521 | :param initially: |
| 4522 | Optional string. If set, emit INITIALLY <value> when issuing DDL |
| 4523 | for this constraint. |
| 4524 | |
| 4525 | :param info: Optional data dictionary which will be populated into the |
| 4526 | :attr:`.SchemaItem.info` attribute of this object. |
| 4527 | |
| 4528 | """ |
| 4529 | |
| 4530 | self.sqltext = coercions.expect(roles.DDLExpressionRole, sqltext) |
| 4531 | columns: List[Column[Any]] = [] |
| 4532 | visitors.traverse(self.sqltext, {}, {"column": columns.append}) |
| 4533 | |
| 4534 | super().__init__( |
| 4535 | name=name, |
| 4536 | deferrable=deferrable, |
| 4537 | initially=initially, |
| 4538 | _create_rule=_create_rule, |
| 4539 | info=info, |
| 4540 | _type_bound=_type_bound, |
| 4541 | _autoattach=_autoattach, |
| 4542 | *columns, |
| 4543 | **dialect_kw, |
| 4544 | ) |
| 4545 | if table is not None: |
| 4546 | self._set_parent_with_dispatch(table) |
| 4547 |
nothing calls this directly
no test coverage detected