-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow calling variadic functions with repeated parameters #1603
Allow calling variadic functions with repeated parameters #1603
Conversation
b687885
to
f7195e7
Compare
01b2812
to
2c14ddd
Compare
Rebased on current master and refactored:
|
2c14ddd
to
15a0570
Compare
9ac55c2
to
a559f53
Compare
a559f53
to
bb3a481
Compare
Only one thing left to do for me: run a load test and see if the PR has an impact on non-variadic RPC. (Once #1609 is finished, we'll check this automatically) |
In the meantime I will have to dig out the piece of documentation I had already started and update that. |
bb3a481
to
35da734
Compare
35da734
to
62893c6
Compare
rebased on master with merge conflict resolved; docs PR is done. |
I think I can refactor this a bit, but I'll do it on another PR. Looks good to merge 🚀 (Docs on PostgREST/postgrest-docs#357) |
Remake of #1552 - new PR for a clean history and easier discussion. Resolves #1470.
This implements variadic arguments for RPCs by either:
See the test cases for some examples.
To be able to implement this, I had to do the following in 3 commits
findProc
from App to ApiRequest, to be able to later use the result offindProc
already when parsing the query string - to make sure to only include repeated params for the variadic case and not for regular functions. This also lead to a change inTargetProc
, which is now passing theProcDescription
instead of only aQualifiedIdentifier
around. To still support the fallback case (i.e. when the schema cache is stale or something) I added a fallbackProcDescription
to findProc which basically serves only as a container for the identifier which was passed around in that case before. This change also has the side-effect of providing some defaults (volatility, return type), so the places where those were used do not need to make a decision about fallbacks anymore.payloadColumns
andmapFromListWithMultiple
. The latter just appends all params into a list and passes them either as a JSON Array (if variadic) or takes the first element of that list (if non-variadic). For the variadic decision, the result offindProc
is needed, which in turn is based onpayloadColumns
. To avoid a circular dependency I had to changepayloadColumns
a bit, so that it does not depend onpayload
(which depends onmapFromListWithMultiple
...) anymore, at least in the cases where we parse the query string.Note:
The n=1 and n>1 cases are handled through
mapFromListWithMultiple
or an array in the JSON body. For n=0:DEFAULT '{}'
to the functions variadic argument definition. This is in line with the default behaviour of postgres.