From 76e658ee129a49afc74152b57330cf2c2e653e2e Mon Sep 17 00:00:00 2001 From: Yosry Muhammad Date: Thu, 1 Aug 2019 14:29:38 +0100 Subject: [PATCH] Ensure command tags are shown in the messages tab of the Query Tool. Fixes #4520 --- docs/en_US/release_notes_4_12.rst | 3 ++- web/pgadmin/tools/sqleditor/__init__.py | 23 ++++++++++--------- .../tools/sqleditor/tests/test_view_data.py | 2 +- .../utils/tests/test_save_changed_data.py | 2 +- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/en_US/release_notes_4_12.rst b/docs/en_US/release_notes_4_12.rst index 4b680b79a..ce9a70f7a 100644 --- a/docs/en_US/release_notes_4_12.rst +++ b/docs/en_US/release_notes_4_12.rst @@ -26,4 +26,5 @@ Bug fixes | `Issue #4496 `_ - Ensure columns can be created when they are IDENTITY fields with the CYCLE option enabled. | `Issue #4497 `_ - Ensure purely numeric comments can be saved on new columns. | `Issue #4508 `_ - Fix accessibility issue for Datetime cell in backgrid. -| `Issue #4520 `_ - Ensure the query tool will work with older versions of psycopg2 than we officially support, albeit without updatable resultsets. \ No newline at end of file +| `Issue #4520 `_ - Ensure the query tool will work with older versions of psycopg2 than we officially support, albeit without updatable resultsets. +| `Issue #4525 `_ - Ensure command tags are shown in the messages tab of the Query Tool. \ No newline at end of file diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index 4fe4d7da6..5091c11dd 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -399,17 +399,6 @@ def poll(trans_id): additional_messages = ''.join(messages) notifies = conn.get_notifies() - # Procedure/Function output may comes in the form of Notices - # from the database server, so we need to append those outputs - # with the original result. - if result is None: - result = conn.status_message() - if (result != 'SELECT 1' or result != 'SELECT 0') and \ - result is not None and additional_messages: - result = additional_messages + result - else: - result = None - if st: if 'primary_keys' in session_obj: primary_keys = session_obj['primary_keys'] @@ -496,6 +485,7 @@ def poll(trans_id): col_info['pgadmin_alias'] = \ re.sub("[%()]+", "|", col_name) session_obj['columns_info'] = columns + # status of async_fetchmany_2darray is True and result is none # means nothing to fetch if result and rows_affected > -1: @@ -516,6 +506,17 @@ def poll(trans_id): # restore it and update the session variable. update_session_grid_transaction(trans_id, session_obj) + # Procedure/Function output may comes in the form of Notices + # from the database server, so we need to append those outputs + # with the original result. + if result is None: + result = conn.status_message() + if result is not None and additional_messages is not None: + result = additional_messages + result + else: + result = result if result is not None \ + else additional_messages + elif status == ASYNC_EXECUTION_ABORTED: status = 'Cancel' else: diff --git a/web/pgadmin/tools/sqleditor/tests/test_view_data.py b/web/pgadmin/tools/sqleditor/tests/test_view_data.py index dc96f9cde..b02e0e905 100644 --- a/web/pgadmin/tools/sqleditor/tests/test_view_data.py +++ b/web/pgadmin/tools/sqleditor/tests/test_view_data.py @@ -33,7 +33,7 @@ class TestViewData(BaseTestGenerator): json_val json Not Null, Constraint table_pk Primary Key(id) );""", - result_data=None, + result_data='SELECT 0', rows_fetched_to=0 ) ) diff --git a/web/pgadmin/tools/sqleditor/utils/tests/test_save_changed_data.py b/web/pgadmin/tools/sqleditor/utils/tests/test_save_changed_data.py index 1745a9905..8a4a0bd83 100644 --- a/web/pgadmin/tools/sqleditor/utils/tests/test_save_changed_data.py +++ b/web/pgadmin/tools/sqleditor/utils/tests/test_save_changed_data.py @@ -251,7 +251,7 @@ class TestSaveChangedData(BaseTestGenerator): }, save_status=True, check_sql='SELECT * FROM %s WHERE pk_col = 2', - check_result=None + check_result='SELECT 0' )), ]