MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _copy

Method _copy

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

Source from the content-addressed store, hash-verified

5239 return self._copy(schema=schema, target_table=target_table, **kw)
5240
5241 def _copy(
5242 self,
5243 *,
5244 schema: Optional[str] = None,
5245 target_table: Optional[Table] = None,
5246 **kw: Any,
5247 ) -> ForeignKeyConstraint:
5248 fkc = ForeignKeyConstraint(
5249 [x.parent.key for x in self.elements],
5250 [
5251 x._get_colspec(
5252 schema=schema,
5253 table_name=(
5254 target_table.name
5255 if target_table is not None
5256 and x._table_key_within_construction()
5257 == x.parent.table.key
5258 else None
5259 ),
5260 _is_copy=True,
5261 )
5262 for x in self.elements
5263 ],
5264 name=self.name,
5265 onupdate=self.onupdate,
5266 ondelete=self.ondelete,
5267 use_alter=self.use_alter,
5268 deferrable=self.deferrable,
5269 initially=self.initially,
5270 link_to_name=self.link_to_name,
5271 match=self.match,
5272 comment=self.comment,
5273 )
5274 for self_fk, other_fk in zip(self.elements, fkc.elements):
5275 self_fk._schema_item_copy(other_fk)
5276 return self._schema_item_copy(fkc)
5277
5278
5279class PrimaryKeyConstraint(ColumnCollectionConstraint):

Callers 2

copyMethod · 0.95
test_fk_copyMethod · 0.95

Calls 4

_get_colspecMethod · 0.80
_schema_item_copyMethod · 0.80

Tested by 1

test_fk_copyMethod · 0.76