Skip to content

Function request: diag_query( :sql, :description ) #228

Open
@floratmin

Description

@floratmin

Hello,
i started to use tap and for my testing scenarios i need to pretty print queries before and after i run a function. But when i raise a notice it is not printed together with the test output, but before.
I thought maybe this could be a valuable feature for using pgTap.

I was thinking about something like:

create function schema.pretty_print_sql() returns setof text as $$
begin
return next diag_query('select a as "fieldA", b from tables where conditions', 'Explanation');
return next is(1, 1, 'test explanation);
end;
$$ language plpgsql;

and with runtests('schema'::name);

should yield something like

          runtests
----------------------------
# |-----------------------|
# | Explanation           |
# |-----------------------|
# | fieldA | b            |
# |=======================|
# | 1      | someText     |
# | 2      | someMoreText |
# |=======================|
ok 1 - test explanation
1..1

ok 1 - schema.pretty_print_sql
1..1

Best Florian

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions