| 4857 | return self._copy(schema=schema, target_table=target_table, **kw) |
| 4858 | |
| 4859 | def _copy( |
| 4860 | self, |
| 4861 | *, |
| 4862 | schema: Optional[str] = None, |
| 4863 | target_table: Optional[Table] = None, |
| 4864 | **kw: Any, |
| 4865 | ) -> ForeignKeyConstraint: |
| 4866 | fkc = ForeignKeyConstraint( |
| 4867 | [x.parent.key for x in self.elements], |
| 4868 | [ |
| 4869 | x._get_colspec( |
| 4870 | schema=schema, |
| 4871 | table_name=( |
| 4872 | target_table.name |
| 4873 | if target_table is not None |
| 4874 | and x._table_key() == x.parent.table.key |
| 4875 | else None |
| 4876 | ), |
| 4877 | _is_copy=True, |
| 4878 | ) |
| 4879 | for x in self.elements |
| 4880 | ], |
| 4881 | name=self.name, |
| 4882 | onupdate=self.onupdate, |
| 4883 | ondelete=self.ondelete, |
| 4884 | use_alter=self.use_alter, |
| 4885 | deferrable=self.deferrable, |
| 4886 | initially=self.initially, |
| 4887 | link_to_name=self.link_to_name, |
| 4888 | match=self.match, |
| 4889 | comment=self.comment, |
| 4890 | ) |
| 4891 | for self_fk, other_fk in zip(self.elements, fkc.elements): |
| 4892 | self_fk._schema_item_copy(other_fk) |
| 4893 | return self._schema_item_copy(fkc) |
| 4894 | |
| 4895 | |
| 4896 | class PrimaryKeyConstraint(ColumnCollectionConstraint): |