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

Functions that return a table #1

Open
ghost opened this issue Dec 29, 2020 · 2 comments
Open

Functions that return a table #1

ghost opened this issue Dec 29, 2020 · 2 comments

Comments

@ghost
Copy link

ghost commented Dec 29, 2020

Hi @nettofarah , this is a super useful tool. Do you know if it would be possible to generate types for functions that return a table? Like for example:

CREATE FUNCTION get_groups()
    RETURNS TABLE (
        group_id integer,
        group_name text
    )
    LANGUAGE sql
AS $$
    -- SELECT ...
$$;

I would expect it to generate:

export interface get_groups {
  group_id: number
  group_name: string
}
@nettofarah
Copy link
Owner

Hey, @joaopaulobdac. Thanks for the suggestion.
This is the first time I hear about functions that return tables.

Would you like to start a pull request? I'm happy to help out any way I can. Maybe start with an unit/integration test, and I could help fill in the blanks with some implementation code?

@ghost
Copy link
Author

ghost commented Dec 31, 2020

Yeah! I will be occupied in january because I have a couple of important exams in the upcoming weeks but after that I can start. You can use this type of function similarly to a view, with the benefit of being able to pass parameters to it.

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

No branches or pull requests

1 participant