Return a new selectable with the specified label style. There are three "label styles" available, :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY`, :attr:`_sql.SelectLabelStyle.LABEL_STYLE_TABLENAME_PLUS_COL`, and :attr:`_sql.SelectLabelStyle.LABEL_STYLE_N
(self, style: SelectLabelStyle)
| 4188 | return self._label_style |
| 4189 | |
| 4190 | def set_label_style(self, style: SelectLabelStyle) -> Self: |
| 4191 | """Return a new selectable with the specified label style. |
| 4192 | |
| 4193 | There are three "label styles" available, |
| 4194 | :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY`, |
| 4195 | :attr:`_sql.SelectLabelStyle.LABEL_STYLE_TABLENAME_PLUS_COL`, and |
| 4196 | :attr:`_sql.SelectLabelStyle.LABEL_STYLE_NONE`. The default style is |
| 4197 | :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY`. |
| 4198 | |
| 4199 | In modern SQLAlchemy, there is not generally a need to change the |
| 4200 | labeling style, as per-expression labels are more effectively used by |
| 4201 | making use of the :meth:`_sql.ColumnElement.label` method. In past |
| 4202 | versions, :data:`_sql.LABEL_STYLE_TABLENAME_PLUS_COL` was used to |
| 4203 | disambiguate same-named columns from different tables, aliases, or |
| 4204 | subqueries; the newer :data:`_sql.LABEL_STYLE_DISAMBIGUATE_ONLY` now |
| 4205 | applies labels only to names that conflict with an existing name so |
| 4206 | that the impact of this labeling is minimal. |
| 4207 | |
| 4208 | The rationale for disambiguation is mostly so that all column |
| 4209 | expressions are available from a given :attr:`_sql.FromClause.c` |
| 4210 | collection when a subquery is created. |
| 4211 | |
| 4212 | .. versionadded:: 1.4 - the |
| 4213 | :meth:`_sql.GenerativeSelect.set_label_style` method replaces the |
| 4214 | previous combination of ``.apply_labels()``, ``.with_labels()`` and |
| 4215 | ``use_labels=True`` methods and/or parameters. |
| 4216 | |
| 4217 | .. seealso:: |
| 4218 | |
| 4219 | :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DISAMBIGUATE_ONLY` |
| 4220 | |
| 4221 | :attr:`_sql.SelectLabelStyle.LABEL_STYLE_TABLENAME_PLUS_COL` |
| 4222 | |
| 4223 | :attr:`_sql.SelectLabelStyle.LABEL_STYLE_NONE` |
| 4224 | |
| 4225 | :attr:`_sql.SelectLabelStyle.LABEL_STYLE_DEFAULT` |
| 4226 | |
| 4227 | """ |
| 4228 | if self._label_style is not style: |
| 4229 | self = self._generate() |
| 4230 | self._label_style = style |
| 4231 | return self |
| 4232 | |
| 4233 | @property |
| 4234 | def _group_by_clause(self) -> ClauseList: |