-
-
Notifications
You must be signed in to change notification settings - Fork 11
Add parameters and volatility to Function #104
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
base: main
Are you sure you want to change the base?
Add parameters and volatility to Function #104
Conversation
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.
honestly this looks really good! I left a couple of comments that I'd consider optional, so lmk if you plan to address them or not and i'll either await the update or merge as-is
src/sqlalchemy_declarative_extensions/dialects/postgresql/function.py
Outdated
Show resolved
Hide resolved
src/sqlalchemy_declarative_extensions/dialects/postgresql/query.py
Outdated
Show resolved
Hide resolved
JK i just rebased the PR version, but just something to be aware of if/when you develop on top of this. |
952377d
to
12fe2d2
Compare
@DanCardin Thank you very much for your comments! And also for resolving the issue with the CI. I've made sure that the tests pass locally, let's hope they pass in CI too! |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #104 +/- ##
==========================================
- Coverage 89.78% 89.43% -0.36%
==========================================
Files 86 86
Lines 3867 4031 +164
Branches 783 836 +53
==========================================
+ Hits 3472 3605 +133
- Misses 322 343 +21
- Partials 73 83 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Hey guys. Happy to see this MR in the pipeline. For a current project, we are currently missing exactly that function to pass arguments to a function. Any plans on your side to fix the ci and release that? Thanks a lot in advance |
i think this is still fairly untested, particularly the different kinds of input types. but i prototyped pulling the individual argument components into a What this does is limit the complexity of any string parsing to a maximum complexity bound from the user input side beyond which the user is just forced to supply the argument in terms of the abstraction. But for retrieving a given definition from postgres itself, it should always be avoiding any fancy parsing. What i'm less clear about is how input/output parameters work. Seems like but variadic/inout/out arguments are all things i haven't personally investigated the use of thus far, and have no idea whether those work. |
returns=FunctionReturn(table=["num integer", "num_squared integer"]), | ||
volatility=FunctionVolatility.IMMUTABLE, | ||
), | ||
) |
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.
There is an issue with the ordering of the arg_types. You can test this by changing the return type of one of the columns:
Function(
"generate_series_squared",
"""
SELECT i::float, i*i
FROM generate_series(1, _limit) as i;
""",
language="sql",
parameters=[FunctionParam("_limit", "integer", default=1)],
returns=FunctionReturn(table=["num float", "num_squared integer"]),
volatility=FunctionVolatility.IMMUTABLE,
),
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.
needed to order the aggregate by the ordinality, mb
(Currently for Postgres only)
14a682e
to
7cd6f58
Compare
7cd6f58
to
3a148aa
Compare
Odds any interested parties want to test out the PR in its current state? It does currently 'regress' relative to the original suggestion allowing |
Resolves #103
This PR adds support for declaring
Function
s withparameters
for both the MySQL and the PostgreSQL dialects. The PostgreSQL dialect ofFunction
s now also support a newvolatility
option, which can be one ofFunctionVolatility.{VOLATILE,STABLE,IMMUTABLE}
.The PR also adds test cases for a variety of
Function
definitions that cover the new features.The PR also updates the ReadTheDocs documentation.