Skip to content
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

Support array literal spread param transform #555

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nick-keller
Copy link
Contributor

The problem

If you want to have a param that is an array that you can pass to a function, you cannot.
For instance:

SELECT FROM my_function(ARRAY['a', 'b', 'c']);

The solution

I added a param transform to allow for array literal spread as shown below.

/*
  @name selectFunctionResult
  @param values -> ARRAY[...]
*/
SELECT FROM my_function(:values);
const parameters = { values: ['a', 'b', 'c'] };
selectSomeUsers.run(parameters, connection);
-- Parameters: ['a', 'b', 'c']
SELECT FROM my_function(ARRAY[$1, $2, $3]);

Unfortunately I am having quite a hard time running everything locally, so maybe @adelsz you should double check on your machine that it works as expected.

Thx!

@nick-keller
Copy link
Contributor Author

Hey @adelsz !
Could you please help me figure this out please. I just cannot get it to work on my machine 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant