Create a *proxy* for this column. This is a copy of this ``Column`` referenced by a different parent (such as an alias or select statement). The column should be used only in select scenarios, as its full DDL/default information is not transferred.
(
self,
selectable: FromClause,
primary_key: ColumnSet,
foreign_keys: Set[KeyedColumnElement[Any]],
name: Optional[str] = None,
key: Optional[str] = None,
name_is_truncatable: bool = False,
compound_select_cols: Optional[
_typing_Sequence[ColumnElement[Any]]
] = None,
**kw: Any,
)
| 2619 | new_fk._set_parent(other) |
| 2620 | |
| 2621 | def _make_proxy( |
| 2622 | self, |
| 2623 | selectable: FromClause, |
| 2624 | primary_key: ColumnSet, |
| 2625 | foreign_keys: Set[KeyedColumnElement[Any]], |
| 2626 | name: Optional[str] = None, |
| 2627 | key: Optional[str] = None, |
| 2628 | name_is_truncatable: bool = False, |
| 2629 | compound_select_cols: Optional[ |
| 2630 | _typing_Sequence[ColumnElement[Any]] |
| 2631 | ] = None, |
| 2632 | **kw: Any, |
| 2633 | ) -> Tuple[str, ColumnClause[_T]]: |
| 2634 | """Create a *proxy* for this column. |
| 2635 | |
| 2636 | This is a copy of this ``Column`` referenced by a different parent |
| 2637 | (such as an alias or select statement). The column should |
| 2638 | be used only in select scenarios, as its full DDL/default |
| 2639 | information is not transferred. |
| 2640 | |
| 2641 | """ |
| 2642 | |
| 2643 | fk = [ |
| 2644 | ForeignKey( |
| 2645 | col if col is not None else f._colspec, |
| 2646 | _unresolvable=col is None, |
| 2647 | _constraint=f.constraint, |
| 2648 | ) |
| 2649 | for f, col in [ |
| 2650 | (fk, fk._resolve_column(raiseerr=False)) |
| 2651 | for fk in self.foreign_keys |
| 2652 | ] |
| 2653 | ] |
| 2654 | |
| 2655 | if name is None and self.name is None: |
| 2656 | raise exc.InvalidRequestError( |
| 2657 | "Cannot initialize a sub-selectable" |
| 2658 | " with this Column object until its 'name' has " |
| 2659 | "been assigned." |
| 2660 | ) |
| 2661 | try: |
| 2662 | c = self._constructor( |
| 2663 | ( |
| 2664 | coercions.expect( |
| 2665 | roles.TruncatedLabelRole, name if name else self.name |
| 2666 | ) |
| 2667 | if name_is_truncatable |
| 2668 | else (name or self.name) |
| 2669 | ), |
| 2670 | self.type, |
| 2671 | # this may actually be ._proxy_key when the key is incoming |
| 2672 | key=key if key else name if name else self.key, |
| 2673 | primary_key=self.primary_key, |
| 2674 | nullable=self.nullable, |
| 2675 | _proxies=( |
| 2676 | list(compound_select_cols) |
| 2677 | if compound_select_cols |
| 2678 | else [self] |
no test coverage detected