the plpgsql function:
CREATE OR REPLACE FUNCTION testarray (int[]) returns int as $$
DECLARE
len int;
BEGIN
len := array_upper($1);
return len;
END
$$ language plpgsql;
the node-postgres query + test array:
var ta = [1,2,3,4,5];
client.query('SELECT testarray($1)', [ta], function(err, result) {
console.log('err: ' + err);
console.log('result: ' + result);
});
output from node server:
err: error: array value must start with "{" or dimension information
result: undefined
I also tried cast the parameter in the client query like testarray($1::int[]) which returned the same error.
I changed the function argument to (anyarray int) and the output error changed:
err: error: invalid input syntax for integer: "1,2,3,4,5"
result: undefined
and a couple other variations.
I seek the variation that produces no error and returns 5.
i read the post-gres parse-array issue: https://github.com/brianc/node-postgres/issues/10 and the stackoverflow question on parameterised arrays in node-postgres : node-postgres: how to execute "WHERE col IN (<dynamic value list>)" query? but the answer didn't seem to be there.