]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Add FunctionElement.aggregate_order_by
authorReuven Starodubski <reuven.s@claroty.com>
Thu, 11 Sep 2025 17:33:59 +0000 (13:33 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 19 Sep 2025 13:38:57 +0000 (09:38 -0400)
commit459ebc668a5512be412c7b73dc6a4468363bf274
tree4a1fb88fd07f480f631af708a503f621363c404d
parent3e151fc411f0a28b3a1d9da899a44672e62584fb
Add FunctionElement.aggregate_order_by

Added new generalized aggregate function ordering to functions via the
:func:`_functions.FunctionElement.aggregate_order_by` method, which
receives an expression and generates the appropriate embedded "ORDER BY" or
"WITHIN GROUP (ORDER BY)" phrase depending on backend database.  This new
function supersedes the use of the PostgreSQL
:func:`_postgresql.aggregate_order_by` function, which remains present for
backward compatibility.   To complement the new parameter, the
:paramref:`_functions.aggregate_strings.order_by` which adds ORDER BY
capability to the :class:`_functions.aggregate_strings` dialect-agnostic
function which works for all included backends. Thanks much to Reuven
Starodubski with help on this patch.

Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #12853
Closes: #12856
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12856
Pull-request-sha: d93fb591751227eb1f96052ea3ad449f511f70b3

Change-Id: I8eb41ff2d57695963a358b5f0017ca9372f15f70
23 files changed:
doc/build/changelog/unreleased_21/12853.rst [new file with mode: 0644]
doc/build/core/sqlelement.rst
doc/build/dialects/postgresql.rst
doc/build/tutorial/data_select.rst
lib/sqlalchemy/__init__.py
lib/sqlalchemy/dialects/mssql/base.py
lib/sqlalchemy/dialects/mysql/base.py
lib/sqlalchemy/dialects/oracle/base.py
lib/sqlalchemy/dialects/postgresql/base.py
lib/sqlalchemy/dialects/postgresql/ext.py
lib/sqlalchemy/dialects/sqlite/base.py
lib/sqlalchemy/engine/default.py
lib/sqlalchemy/engine/interfaces.py
lib/sqlalchemy/sql/__init__.py
lib/sqlalchemy/sql/_elements_constructors.py
lib/sqlalchemy/sql/compiler.py
lib/sqlalchemy/sql/elements.py
lib/sqlalchemy/sql/expression.py
lib/sqlalchemy/sql/functions.py
test/dialect/postgresql/test_types.py
test/sql/test_compare.py
test/sql/test_compiler.py
test/sql/test_functions.py