Skip to content

Commit 695f870

Browse files
authored
Fixed an issue where the query tool returns "cannot unpack non-iterable Response object" when running any query with a database name change. #8607
1 parent 593b111 commit 695f870

3 files changed

Lines changed: 13 additions & 3 deletions

File tree

web/pgadmin/tools/sqleditor/__init__.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,11 @@ def check_transaction_status(trans_id, auto_comp=False):
790790
return False, internal_server_error(errormsg=str(e)), None, None, None
791791

792792
if connect and conn and not conn.connected():
793-
conn.connect()
793+
status, errmsg = conn.connect()
794+
if not status:
795+
current_app.logger.error(errmsg)
796+
return (False, internal_server_error(errormsg=str(errmsg)),
797+
None, None, None)
794798

795799
return True, None, conn, trans_obj, session_obj
796800

@@ -818,6 +822,9 @@ def start_view_data(trans_id):
818822
info='DATAGRID_TRANSACTION_REQUIRED',
819823
status=404)
820824

825+
if not status and error_msg and type(error_msg) is Response:
826+
return error_msg
827+
821828
# get the default connection as current connection which is attached to
822829
# trans id holds the cursor which has query result so we cannot use that
823830
# connection to execute another query otherwise we'll lose query result.

web/pgadmin/tools/sqleditor/utils/query_tool_connection_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def query_tool_connection_check(trans_id):
5959
status, msg = conn.connect()
6060
if not status:
6161
current_app.logger.error(msg)
62-
return internal_server_error(errormsg=str(msg))
62+
return status, msg, None, None, None, None
6363
return status, None, conn, transaction_object, session_obj, None
6464
else:
6565
status = False

web/pgadmin/tools/sqleditor/utils/start_running_query.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ def execute(self, sql, trans_id, http_session, connect=False):
8484
from pgadmin.tools.sqleditor.utils import \
8585
query_tool_connection_check
8686

87-
_, _, _, _, _, response = \
87+
status, errmsg, _, _, _, response = \
8888
query_tool_connection_check(trans_id)
89+
# If database does not exist then show error msg
90+
if not status:
91+
result = errmsg
8992
# This is required for asking user to enter password
9093
# when password is not saved for the server
9194
if response is not None:

0 commit comments

Comments
 (0)