]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commit
Type array_agg() 12461/head
authorDenis Laxalde <denis@laxalde.org>
Mon, 24 Mar 2025 13:59:25 +0000 (14:59 +0100)
committerDenis Laxalde <denis@laxalde.org>
Mon, 24 Mar 2025 16:58:49 +0000 (17:58 +0100)
commitba27cbb8639dcd35127ab6a2928b7b5b3667e287
treea726b3908adae8682c054725f4f872ca23e2e85e
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
accordingly.

Also add a couple of hand-written typing tests for PostgreSQL.
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