]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Type array_agg()
authorDenis Laxalde <denis@laxalde.org>
Mon, 24 Mar 2025 20:35:07 +0000 (16:35 -0400)
committerFederico Caselli <cfederico87@gmail.com>
Tue, 25 Mar 2025 22:37:32 +0000 (23:37 +0100)
commit56600630ffec6929c167c053fb852b0d77d55f14
treea78206e1c59676a8048246c7dee1c77ffbc291c2
parent022132e36dfa6297ca5b84681934de5740ce2d4f
Type array_agg()

The return type of `array_agg()` is declared as a `Sequence[T]` where `T` is bound to the type of input argument.

This is implemented by making `array_agg()` inheriting from `ReturnTypeFromArgs` which provides appropriate overloads of `__init__()` to support this.

This usage of ReturnTypeFromArgs is a bit different from previous ones as the return type of the function is not exactly the same as that of its arguments, but a "collection" (a generic, namely a Sequence here) of the argument types.  Accordingly, we adjust the code of `tools/generate_sql_functions.py` to retrieve the "collection" type from 'fn_class' annotation and generate expected return type.

Also add a couple of hand-written typing tests for PostgreSQL.

Related to #6810

Closes: #12461
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/12461
Pull-request-sha: ba27cbb8639dcd35127ab6a2928b7b5b3667e287

Change-Id: I3fd538cc7092a0492c26970f0b825bf70ddb66cd
(cherry picked from commit 543acbd8d1c7e3037877ca74a6b05f62592ef153)
lib/sqlalchemy/sql/functions.py
test/typing/plain_files/dialects/postgresql/pg_stuff.py
test/typing/plain_files/sql/functions.py
tools/generate_sql_functions.py