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

Computed column function optional arguments are not accounted for when values are passed #2215

Open
Tam opened this issue Oct 18, 2024 · 1 comment
Labels

Comments

@Tam
Copy link
Contributor

Tam commented Oct 18, 2024

Summary

Optional function arguments on computed columns are not accounted for when values are passed to the function. This means if you skip an optional parameter, the next parameter is passed in it's place and will be wrong.

Steps to reproduce

The function below accepts two ints and one float.

create function public.image_src (
  image public.image
, width int = null
, height int = null
, aspect float = null
) returns varchar as $$ ... $$ language plpgsql immutable;

When called from GraphQL the generated SQL looks like this:

{
  src (width: 100, aspect: 1)
}
public.image_src(
  __image__
, __image_identifiers__."id1"
, __image_identifiers__."id2"
);

The last argument is in the wrong place and will error, in this case: ERROR: function public.image_src(image, integer, double precision) does not exist.

Possible Solution

Use named parameters when calling computed functions with parameters, so:

public.image_src(
  __image__
, width => __image_identifiers__."id1"
, aspect => __image_identifiers__."id2"
);
@Tam Tam added the 🐛 bug label Oct 18, 2024
@benjie
Copy link
Member

benjie commented Oct 18, 2024

Hmmm; that's weird, it should be using named parameters.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: 🦟 Mayfly
Development

No branches or pull requests

2 participants