mirror of https://github.com/dbcli/pgcli
Raised notices (#1450)
* Fix - Raised notices are printed backwards #1443 * updated changelog * removed a print * fixed up syntax error * removing unneeded Nones from output * rem var due to github recommendation * adjusting if statements.
This commit is contained in:
parent
e2ff38d170
commit
27b2bc2d37
|
@ -9,6 +9,7 @@ Bug fixes:
|
|||
----------
|
||||
|
||||
* Fix display of "short host" in prompt (with `\h`) for IPv4 addresses ([issue 964](https://github.com/dbcli/pgcli/issues/964)).
|
||||
* Fix backwards display of NOTICEs from a Function ([issue 1443](https://github.com/dbcli/pgcli/issues/1443))
|
||||
|
||||
|
||||
==================
|
||||
|
|
|
@ -437,7 +437,11 @@ class PGExecute:
|
|||
|
||||
def handle_notices(n):
|
||||
nonlocal title
|
||||
title = f"{n.message_primary}\n{n.message_detail}\n{title}"
|
||||
title = f"{title}"
|
||||
if n.message_primary is not None:
|
||||
title = f"{title}\n{n.message_primary}"
|
||||
if n.message_detail is not None:
|
||||
title = f"{title}\n{n.message_detail}"
|
||||
|
||||
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,38 @@ 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 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;
|
||||
""",
|
||||
)
|
||||
|
||||
executor.function_definition("demo_order")
|
||||
|
||||
result = run(executor, "select demo_order()")
|
||||
assert "first\nsecond\nthird\nfourth\nfifth\nsixth" 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]
|
||||
|
||||
|
||||
@dbtest
|
||||
def test_view_definition(executor):
|
||||
run(executor, "create table tbl1 (a text, b numeric)")
|
||||
|
|
Loading…
Reference in New Issue