-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Type array_agg() #12461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type array_agg() #12461
Conversation
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change looks ok, but I want to try cleaning up the overloads, since that type is used generically in all()
for example
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, this is sqla-tester setting up my work on behalf of CaselIT to try to get revision ba27cbb of this pull request into gerrit so we can run tests and reviews and stuff
New Gerrit review created for change ba27cbb: https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/5797 |
thanks! |
Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/5797 has been merged. Congratulations! :) |
Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/5798 has been merged. Congratulations! :) |
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: #12461 Pull-request-sha: ba27cbb Change-Id: I3fd538cc7092a0492c26970f0b825bf70ddb66cd (cherry picked from commit 543acbd)
The return type of
array_agg()
is declared as aSequence[T]
whereT
is bound to the type of input argument.This is implemented by making
array_agg()
inheriting fromReturnTypeFromArgs
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