Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raised notices #1450

Merged
merged 7 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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))


==================
Expand Down
2 changes: 1 addition & 1 deletion pgcli/pgexecute.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def execute_normal_sql(self, split_sql):

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)

Expand Down
1 change: 1 addition & 0 deletions tests/features/steps/crud_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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
Expand Down
34 changes: 34 additions & 0 deletions tests/test_pgexecute.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,40 @@
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;
""",
)
result = executor.function_definition("demo_order")
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed

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]


@dbtest
def test_view_definition(executor):
run(executor, "create table tbl1 (a text, b numeric)")
Expand Down
Loading