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)
| 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'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: |