MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / add_columns

Method add_columns

lib/sqlalchemy/sql/selectable.py:6176–6210  ·  view source on GitHub ↗

r"""Return a new :func:`_expression.select` construct with the given entities appended to its columns clause. E.g.:: my_select = my_select.add_columns(table.c.new_column) The original expressions in the columns clause remain in place. To replace the ori

(
        self, *entities: _ColumnsClauseArgument[Any]
    )

Source from the content-addressed store, hash-verified

6174
6175 @_generative
6176 def add_columns(
6177 self, *entities: _ColumnsClauseArgument[Any]
6178 ) -> Select[Unpack[TupleAny]]:
6179 r"""Return a new :func:`_expression.select` construct with
6180 the given entities appended to its columns clause.
6181
6182 E.g.::
6183
6184 my_select = my_select.add_columns(table.c.new_column)
6185
6186 The original expressions in the columns clause remain in place.
6187 To replace the original expressions with new ones, see the method
6188 :meth:`_expression.Select.with_only_columns`.
6189
6190 :param \*entities: column, table, or other entity expressions to be
6191 added to the columns clause
6192
6193 .. seealso::
6194
6195 :meth:`_expression.Select.with_only_columns` - replaces existing
6196 expressions rather than appending.
6197
6198 :ref:`orm_queryguide_select_multiple_entities` - ORM-centric
6199 example
6200
6201 """
6202 self._reset_memoizations()
6203
6204 self._raw_columns = self._raw_columns + [
6205 coercions.expect(
6206 roles.ColumnsClauseRole, column, apply_propagate_attrs=self
6207 )
6208 for column in entities
6209 ]
6210 return self
6211
6212 def _set_entities(
6213 self, entities: Iterable[_ColumnsClauseArgument[Any]]

Callers 1

columnMethod · 0.95

Calls 1

_reset_memoizationsMethod · 0.80

Tested by

no test coverage detected