mirror of https://github.com/dbcli/pgcli
Fix - Raised notices are printed backwards #1443
This commit is contained in:
parent
e2ff38d170
commit
abaebdbffe
|
@ -437,7 +437,7 @@ class PGExecute:
|
|||
|
||||
def handle_notices(n):
|
||||
nonlocal title
|
||||
title = f"{n.message_primary}\n{n.message_detail}\n{title}"
|
||||
title = f"{title}{n.message_primary}\n{n.message_detail}\n"
|
||||
|
||||
self.conn.add_notice_handler(handle_notices)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ Steps for behavioral style tests are defined in this module.
|
|||
Each step is defined by the string decorating it.
|
||||
This string is used to call the step in "*.feature" file.
|
||||
"""
|
||||
|
||||
import pexpect
|
||||
|
||||
from behave import when, then
|
||||
|
|
|
@ -690,6 +690,42 @@ def test_function_definition(executor):
|
|||
result = executor.function_definition("the_number_three")
|
||||
|
||||
|
||||
@dbtest
|
||||
def test_function_notice_order(executor):
|
||||
run(
|
||||
executor,
|
||||
"""
|
||||
CREATE OR REPLACE FUNCTION pgcli_demo_order() RETURNS VOID AS
|
||||
$$
|
||||
BEGIN
|
||||
RAISE NOTICE 'first';
|
||||
RAISE NOTICE 'second';
|
||||
RAISE NOTICE 'third';
|
||||
RAISE NOTICE 'fourth';
|
||||
RAISE NOTICE 'fifth';
|
||||
RAISE NOTICE 'sixth';
|
||||
END;
|
||||
$$
|
||||
LANGUAGE plpgsql;
|
||||
""",
|
||||
)
|
||||
result = executor.function_definition("pgcli_demo_order")
|
||||
|
||||
result = run(executor, "select demo_order()")
|
||||
assert (
|
||||
"first\nNone\nsecond\nNone\nthird\nNone\nfourth\nNone\nfifth\nNone\nsixth\nNone\n"
|
||||
in result[0]
|
||||
)
|
||||
assert "+------------+" in result[1]
|
||||
assert "| demo_order |" in result[2]
|
||||
assert "|------------|" in result[3]
|
||||
assert "| |" in result[4]
|
||||
assert "+------------+" in result[5]
|
||||
assert "SELECT 1" in result[6]
|
||||
|
||||
print(result)
|
||||
|
||||
|
||||
@dbtest
|
||||
def test_view_definition(executor):
|
||||
run(executor, "create table tbl1 (a text, b numeric)")
|
||||
|
|
Loading…
Reference in New Issue