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,
)
| 4868 | ":paramref:`.CheckConstraint.sqltext`", |
| 4869 | ) |
| 4870 | def __init__( |
| 4871 | self, |
| 4872 | sqltext: _TextCoercedExpressionArgument[Any], |
| 4873 | name: _ConstraintNameArgument = None, |
| 4874 | deferrable: Optional[bool] = None, |
| 4875 | initially: Optional[str] = None, |
| 4876 | table: Optional[Table] = None, |
| 4877 | info: Optional[_InfoType] = None, |
| 4878 | _create_rule: Optional[Any] = None, |
| 4879 | _autoattach: bool = True, |
| 4880 | _type_bound: bool = False, |
| 4881 | **dialect_kw: Any, |
| 4882 | ) -> None: |
| 4883 | r"""Construct a CHECK constraint. |
| 4884 | |
| 4885 | :param sqltext: |
| 4886 | A string containing the constraint definition, which will be used |
| 4887 | verbatim, or a SQL expression construct. If given as a string, |
| 4888 | the object is converted to a :func:`_expression.text` object. |
| 4889 | If the textual |
| 4890 | string includes a colon character, escape this using a backslash:: |
| 4891 | |
| 4892 | CheckConstraint(r"foo ~ E'a(?\:b|c)d") |
| 4893 | |
| 4894 | :param name: |
| 4895 | Optional, the in-database name of the constraint. |
| 4896 | |
| 4897 | :param deferrable: |
| 4898 | Optional bool. If set, emit DEFERRABLE or NOT DEFERRABLE when |
| 4899 | issuing DDL for this constraint. |
| 4900 | |
| 4901 | :param initially: |
| 4902 | Optional string. If set, emit INITIALLY <value> when issuing DDL |
| 4903 | for this constraint. |
| 4904 | |
| 4905 | :param info: Optional data dictionary which will be populated into the |
| 4906 | :attr:`.SchemaItem.info` attribute of this object. |
| 4907 | |
| 4908 | """ |
| 4909 | |
| 4910 | self.sqltext = coercions.expect(roles.DDLExpressionRole, sqltext) |
| 4911 | columns: List[Column[Any]] = [] |
| 4912 | visitors.traverse(self.sqltext, {}, {"column": columns.append}) |
| 4913 | |
| 4914 | super().__init__( |
| 4915 | name=name, |
| 4916 | deferrable=deferrable, |
| 4917 | initially=initially, |
| 4918 | _create_rule=_create_rule, |
| 4919 | info=info, |
| 4920 | _type_bound=_type_bound, |
| 4921 | _autoattach=_autoattach, |
| 4922 | *columns, |
| 4923 | **dialect_kw, |
| 4924 | ) |
| 4925 | if table is not None: |
| 4926 | self._set_parent_with_dispatch(table) |
| 4927 |
nothing calls this directly
no test coverage detected