MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _make_proxy

Method _make_proxy

lib/sqlalchemy/sql/elements.py:1719–1762  ·  view source on GitHub ↗

Create a new :class:`_expression.ColumnElement` representing this :class:`_expression.ColumnElement` as it appears in the select list of a descending selectable.

(
        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[Sequence[ColumnElement[Any]]] = None,
        **kw: Any,
    )

Source from the content-addressed store, hash-verified

1717 return None
1718
1719 def _make_proxy(
1720 self,
1721 selectable: FromClause,
1722 *,
1723 primary_key: ColumnSet,
1724 foreign_keys: Set[KeyedColumnElement[Any]],
1725 name: Optional[str] = None,
1726 key: Optional[str] = None,
1727 name_is_truncatable: bool = False,
1728 compound_select_cols: Optional[Sequence[ColumnElement[Any]]] = None,
1729 **kw: Any,
1730 ) -> typing_Tuple[str, ColumnClause[_T]]:
1731 """Create a new :class:`_expression.ColumnElement` representing this
1732 :class:`_expression.ColumnElement` as it appears in the select list of
1733 a descending selectable.
1734
1735 """
1736 if name is None:
1737 name = self._anon_name_label
1738 if key is None:
1739 key = self._proxy_key
1740 else:
1741 key = name
1742
1743 assert key is not None
1744
1745 co: ColumnClause[_T] = ColumnClause(
1746 (
1747 coercions.expect(roles.TruncatedLabelRole, name)
1748 if name_is_truncatable
1749 else name
1750 ),
1751 type_=getattr(self, "type", None),
1752 _selectable=selectable,
1753 )
1754
1755 co._propagate_attrs = selectable._propagate_attrs
1756 if compound_select_cols:
1757 co._proxies = list(compound_select_cols)
1758 else:
1759 co._proxies = [self]
1760 if selectable._is_clone_of is not None:
1761 co._is_clone_of = selectable._is_clone_of.columns.get(key)
1762 return key, co
1763
1764 def cast(self, type_: _TypeEngineArgument[_OPT]) -> Cast[_OPT]:
1765 """Produce a type cast, i.e. ``CAST(<expression> AS <type>)``.

Callers

nothing calls this directly

Calls 2

ColumnClauseClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected