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

Method _copy

lib/sqlalchemy/sql/schema.py:4425–4455  ·  view source on GitHub ↗
(
        self,
        *,
        target_table: Optional[Table] = None,
        **kw: Any,
    )

Source from the content-addressed store, hash-verified

4423 return self._copy(target_table=target_table, **kw)
4424
4425 def _copy(
4426 self,
4427 *,
4428 target_table: Optional[Table] = None,
4429 **kw: Any,
4430 ) -> ColumnCollectionConstraint:
4431 # ticket #5276
4432 constraint_kwargs = {}
4433 for dialect_name in self.dialect_options:
4434 dialect_options = self.dialect_options[dialect_name]._non_defaults
4435 for (
4436 dialect_option_key,
4437 dialect_option_value,
4438 ) in dialect_options.items():
4439 constraint_kwargs[dialect_name + "_" + dialect_option_key] = (
4440 dialect_option_value
4441 )
4442
4443 assert isinstance(self.parent, Table)
4444 c = self.__class__(
4445 name=self.name,
4446 deferrable=self.deferrable,
4447 initially=self.initially,
4448 *[
4449 _copy_expression(expr, self.parent, target_table)
4450 for expr in self._columns
4451 ],
4452 comment=self.comment,
4453 **constraint_kwargs,
4454 )
4455 return self._schema_item_copy(c)
4456
4457 def contains_column(self, col: Column[Any]) -> bool:
4458 """Return True if this constraint contains the given column.

Callers 1

copyMethod · 0.95

Calls 3

_copy_expressionFunction · 0.85
_schema_item_copyMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected