Construct a new :class:`.AddConstraint` construct. :param element: a :class:`.Constraint` object :param isolate_from_table: optional boolean. Prevents the target :class:`.Constraint` from being rendered inline in a "CONSTRAINT" clause within a CREATE TABLE statem
(
self, element: Constraint, *, isolate_from_table: bool = True
)
| 1130 | __visit_name__ = "add_constraint" |
| 1131 | |
| 1132 | def __init__( |
| 1133 | self, element: Constraint, *, isolate_from_table: bool = True |
| 1134 | ) -> None: |
| 1135 | """Construct a new :class:`.AddConstraint` construct. |
| 1136 | |
| 1137 | :param element: a :class:`.Constraint` object |
| 1138 | |
| 1139 | :param isolate_from_table: optional boolean. Prevents the target |
| 1140 | :class:`.Constraint` from being rendered inline in a "CONSTRAINT" |
| 1141 | clause within a CREATE TABLE statement, in the case that the |
| 1142 | constraint is associated with a :class:`.Table` which is later |
| 1143 | created using :meth:`.Table.create` or :meth:`.MetaData.create_all`. |
| 1144 | This occurs by modifying the state of the :class:`.Constraint` |
| 1145 | object itself such that the CREATE TABLE DDL process will skip it. |
| 1146 | Used for the case when a separate `ALTER TABLE...ADD CONSTRAINT` |
| 1147 | call will be emitted after the `CREATE TABLE` has already occurred. |
| 1148 | ``True`` by default. |
| 1149 | |
| 1150 | .. versionadded:: 2.0.39 - added |
| 1151 | :paramref:`.AddConstraint.isolate_from_table`, defaulting |
| 1152 | to True. Previously, the behavior of this parameter was implicitly |
| 1153 | turned on in all cases. |
| 1154 | |
| 1155 | """ |
| 1156 | super().__init__(element) |
| 1157 | |
| 1158 | if isolate_from_table: |
| 1159 | element._create_rule = self._create_rule_disable |
| 1160 | |
| 1161 | |
| 1162 | class DropConstraint(_DropBase["Constraint"]): |