(self, column: Column[Any], table: Table)
| 3581 | metadata._fk_memos[fk_key].remove(self) |
| 3582 | |
| 3583 | def _set_table(self, column: Column[Any], table: Table) -> None: |
| 3584 | # standalone ForeignKey - create ForeignKeyConstraint |
| 3585 | # on the hosting Table when attached to the Table. |
| 3586 | assert isinstance(table, Table) |
| 3587 | if self.constraint is None: |
| 3588 | self.constraint = ForeignKeyConstraint( |
| 3589 | [], |
| 3590 | [], |
| 3591 | use_alter=self.use_alter, |
| 3592 | name=self.name, |
| 3593 | onupdate=self.onupdate, |
| 3594 | ondelete=self.ondelete, |
| 3595 | deferrable=self.deferrable, |
| 3596 | initially=self.initially, |
| 3597 | match=self.match, |
| 3598 | comment=self.comment, |
| 3599 | **self._unvalidated_dialect_kw, |
| 3600 | ) |
| 3601 | self.constraint._append_element(column, self) |
| 3602 | self.constraint._set_parent_with_dispatch(table) |
| 3603 | table.foreign_keys.add(self) |
| 3604 | # set up remote ".column" attribute, or a note to pick it |
| 3605 | # up when the other Table/Column shows up |
| 3606 | |
| 3607 | _colspec, _ = self._resolve_colspec_argument() |
| 3608 | if isinstance(_colspec, str): |
| 3609 | parenttable, table_key, colname = self._resolve_col_tokens() |
| 3610 | fk_key = (table_key, colname) |
| 3611 | if table_key in parenttable.metadata.tables: |
| 3612 | table = parenttable.metadata.tables[table_key] |
| 3613 | try: |
| 3614 | _column = self._link_to_col_by_colstring( |
| 3615 | parenttable, table, colname |
| 3616 | ) |
| 3617 | except exc.NoReferencedColumnError: |
| 3618 | # this is OK, we'll try later |
| 3619 | pass |
| 3620 | else: |
| 3621 | self._set_target_column(_column) |
| 3622 | |
| 3623 | parenttable.metadata._fk_memos[fk_key].append(self) |
| 3624 | elif hasattr(_colspec, "__clause_element__"): |
| 3625 | _column = _colspec.__clause_element__() |
| 3626 | self._set_target_column(_column) |
| 3627 | else: |
| 3628 | self._set_target_column(_colspec) |
| 3629 | |
| 3630 | |
| 3631 | if TYPE_CHECKING: |
nothing calls this directly
no test coverage detected