MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / selected_columns

Method selected_columns

lib/sqlalchemy/sql/selectable.py:7118–7143  ·  view source on GitHub ↗

A :class:`_expression.ColumnCollection` representing the columns that this SELECT statement or similar construct returns in its result set, not including :class:`_sql.TextClause` constructs. This collection differs from the :attr:`_expression.FromClause.columns`

(
        self,
    )

Source from the content-addressed store, hash-verified

7116
7117 @HasMemoized_ro_memoized_attribute
7118 def selected_columns(
7119 self,
7120 ) -> ColumnCollection[str, KeyedColumnElement[Any]]:
7121 """A :class:`_expression.ColumnCollection`
7122 representing the columns that
7123 this SELECT statement or similar construct returns in its result set,
7124 not including :class:`_sql.TextClause` constructs.
7125
7126 This collection differs from the :attr:`_expression.FromClause.columns`
7127 collection of a :class:`_expression.FromClause` in that the columns
7128 within this collection cannot be directly nested inside another SELECT
7129 statement; a subquery must be applied first which provides for the
7130 necessary parenthesization required by SQL.
7131
7132 For a :class:`_expression.TextualSelect` construct, the collection
7133 contains the :class:`_expression.ColumnElement` objects that were
7134 passed to the constructor, typically via the
7135 :meth:`_expression.TextClause.columns` method.
7136
7137
7138 .. versionadded:: 1.4
7139
7140 """
7141 return ColumnCollection(
7142 (c.key, c) for c in self.column_args
7143 ).as_readonly()
7144
7145 @util.ro_non_memoized_property
7146 def _all_selected_columns(self) -> _SelectIterable:

Callers

nothing calls this directly

Calls 2

ColumnCollectionClass · 0.85
as_readonlyMethod · 0.45

Tested by

no test coverage detected