(self, column: Column[Any], table: Table)
| 3276 | metadata._fk_memos[fk_key].remove(self) |
| 3277 | |
| 3278 | def _set_table(self, column: Column[Any], table: Table) -> None: |
| 3279 | # standalone ForeignKey - create ForeignKeyConstraint |
| 3280 | # on the hosting Table when attached to the Table. |
| 3281 | assert isinstance(table, Table) |
| 3282 | if self.constraint is None: |
| 3283 | self.constraint = ForeignKeyConstraint( |
| 3284 | [], |
| 3285 | [], |
| 3286 | use_alter=self.use_alter, |
| 3287 | name=self.name, |
| 3288 | onupdate=self.onupdate, |
| 3289 | ondelete=self.ondelete, |
| 3290 | deferrable=self.deferrable, |
| 3291 | initially=self.initially, |
| 3292 | match=self.match, |
| 3293 | comment=self.comment, |
| 3294 | **self._unvalidated_dialect_kw, |
| 3295 | ) |
| 3296 | self.constraint._append_element(column, self) |
| 3297 | self.constraint._set_parent_with_dispatch(table) |
| 3298 | table.foreign_keys.add(self) |
| 3299 | # set up remote ".column" attribute, or a note to pick it |
| 3300 | # up when the other Table/Column shows up |
| 3301 | if isinstance(self._colspec, str): |
| 3302 | parenttable, table_key, colname = self._resolve_col_tokens() |
| 3303 | fk_key = (table_key, colname) |
| 3304 | if table_key in parenttable.metadata.tables: |
| 3305 | table = parenttable.metadata.tables[table_key] |
| 3306 | try: |
| 3307 | _column = self._link_to_col_by_colstring( |
| 3308 | parenttable, table, colname |
| 3309 | ) |
| 3310 | except exc.NoReferencedColumnError: |
| 3311 | # this is OK, we'll try later |
| 3312 | pass |
| 3313 | else: |
| 3314 | self._set_target_column(_column) |
| 3315 | |
| 3316 | parenttable.metadata._fk_memos[fk_key].append(self) |
| 3317 | elif hasattr(self._colspec, "__clause_element__"): |
| 3318 | _column = self._colspec.__clause_element__() |
| 3319 | self._set_target_column(_column) |
| 3320 | else: |
| 3321 | _column = self._colspec |
| 3322 | self._set_target_column(_column) |
| 3323 | |
| 3324 | |
| 3325 | if TYPE_CHECKING: |
nothing calls this directly
no test coverage detected