0

We're attempting to run tests against a postgres function that returns a SETOF VARCHAR uppercase strings.

Whenever this test case runs, however, pgTap tries to look up a prepared statement with the same name as the uppercase value we're expecting to be returned. Is there any way of escaping this behaviour or calling this test case in another way to check output?

SELECT set_eq(
  the_function_call(_property := 'value'),
  $$ VALUES ('FIRST_RETURN'), ('SECOND_RETURN') $$,
  'returns both expected values'
);
psql:/path/to/test.test.sql:20: ERROR:  prepared statement "second_return" does not exist
CONTEXT:  SQL statement "CREATE TEMP TABLE __taphave__ AS EXECUTE SECOND_RETURN"

I've tried backslashes, quotes, using UPPER on lowercase strings, casting the values as VARCHAR and ARRAY ['FIRST_RETURN', 'SECOND_RETURN'] as the second argument but still get the same prepared statement issue.

I was trying to avoid creating a prepared statement for each value that literally returns the same value again, but if that's the only way I guess I'll have to relent! Any help greatly appreciated.

Alex
  • 743
  • 7
  • 17

1 Answers1

0

Managed to get this working by changing the way the test is called;

SELECT set_eq(
  $$ SELECT * FROM the_function_call(_property := 'value') $$,
  ARRAY ['FIRST_RETURN', 'SECOND_RETURN'],
  'returns both expected values'
);

Now passes with no issues

Alex
  • 743
  • 7
  • 17