pgtyped icon indicating copy to clipboard operation
pgtyped copied to clipboard

`from (values :my_param)` results in syntax error when `my_param` is `[]`

Open mrjackdavis opened this issue 4 years ago • 0 comments

By example (I've used a similar example to #313, but it's not exactly related)

/*
  @name myQuery
  @param the_param -> ((some_words)...)
*/

insert into app.my_table (the_words)

select
  -- this fn is the reason I need `select from values` instead of just `values :the_param` like the docs
  some_fn(
    my_vals.some_words
  )
from (
  values :the_param
) my_vals (
  some_words
);

When called, if the_param is an empty array, the resulting query is

insert into app.my_table (the_words)

select
  -- this fn is the reason I need `select from values` instead of just `values :the_param` like the docs
  some_fn(
    my_vals.some_words
  )
from (
  values ()
) my_vals (
  some_words
);

Notice values ()

This results in a syntax error ERROR: syntax error at or near ")" at character because values () is invalid

mrjackdavis avatar Aug 21 '21 05:08 mrjackdavis