]> 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>
Mon, 24 Mar 2025 21:22:35 +0000 (22:22 +0100)
commit543acbd8d1c7e3037877ca74a6b05f62592ef153
tree6e10fbf5b96056569b0d9a4a4a7214cea3d2d207
parentdabd77992d785cad89ed110acd2f648a454fb7ae
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
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