From 38008698207dc3703f2565aa8b41f95596724272 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Fri, 19 Sep 2025 10:32:43 -0400 Subject: [PATCH] clarify clauses argument for order_by, group_by Change-Id: Idabfde4a6850a2649a2f32dc42d0320f1ec7692d --- lib/sqlalchemy/sql/selectable.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 08fdadc253..4d72377c2b 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -4368,8 +4368,13 @@ class GenerativeSelect(DialectKWArgs, SelectBase, Generative): stmt = stmt.order_by(None).order_by(new_col) :param \*clauses: a series of :class:`_expression.ColumnElement` - constructs - which will be used to generate an ORDER BY clause. + constructs which will be used to generate an ORDER BY clause. + + Alternatively, an individual entry may also be the string name of a + label located elsewhere in the columns clause of the statement which + will be matched and rendered in a backend-specific way based on + context; see :ref:`tutorial_order_by_label` for background on string + label matching in ORDER BY and GROUP BY expressions. .. seealso:: @@ -4410,8 +4415,13 @@ class GenerativeSelect(DialectKWArgs, SelectBase, Generative): stmt = select(table.c.name, func.max(table.c.stat)).group_by(table.c.name) :param \*clauses: a series of :class:`_expression.ColumnElement` - constructs - which will be used to generate an GROUP BY clause. + constructs which will be used to generate an GROUP BY clause. + + Alternatively, an individual entry may also be the string name of a + label located elsewhere in the columns clause of the statement which + will be matched and rendered in a backend-specific way based on + context; see :ref:`tutorial_order_by_label` for background on string + label matching in ORDER BY and GROUP BY expressions. .. seealso:: -- 2.47.3