MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / set_label_style

Method set_label_style

lib/sqlalchemy/orm/query.py:943–979  ·  view source on GitHub ↗

Apply column labels to the return value of Query.statement. Indicates that this Query's `statement` accessor should return a SELECT statement that applies labels to all columns in the form <tablename>_<columnname>; this is commonly used to disambiguate columns from m

(self, style: SelectLabelStyle)

Source from the content-addressed store, hash-verified

941 return self._label_style
942
943 def set_label_style(self, style: SelectLabelStyle) -> Self:
944 """Apply column labels to the return value of Query.statement.
945
946 Indicates that this Query&#x27;s `statement` accessor should return
947 a SELECT statement that applies labels to all columns in the
948 form <tablename>_<columnname>; this is commonly used to
949 disambiguate columns from multiple tables which have the same
950 name.
951
952 When the `Query` actually issues SQL to load rows, it always
953 uses column labeling.
954
955 .. note:: The :meth:`_query.Query.set_label_style` method *only* applies
956 the output of :attr:`_query.Query.statement`, and *not* to any of
957 the result-row invoking systems of :class:`_query.Query` itself,
958 e.g.
959 :meth:`_query.Query.first`, :meth:`_query.Query.all`, etc.
960 To execute
961 a query using :meth:`_query.Query.set_label_style`, invoke the
962 :attr:`_query.Query.statement` using :meth:`.Session.execute`::
963
964 result = session.execute(
965 query.set_label_style(LABEL_STYLE_TABLENAME_PLUS_COL).statement
966 )
967
968 .. versionadded:: 1.4
969
970
971 .. seealso::
972
973 :meth:`_sql.Select.set_label_style` - v2 equivalent method.
974
975 """ # noqa
976 if self._label_style is not style:
977 self = self._generate()
978 self._label_style = style
979 return self
980
981 @_generative
982 def enable_assertions(self, value: bool) -> Self:

Callers 15

with_labelsMethod · 0.95
_legacy_from_selfMethod · 0.95
_create_orm_contextMethod · 0.45
_subclass_load_via_inMethod · 0.45
subqueryMethod · 0.45
__clause_element__Method · 0.45
existsMethod · 0.45
goMethod · 0.45
test_order_byMethod · 0.45

Calls 1

_generateMethod · 0.45