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

Fixed the query tool issue where raise Notice from func/proc or code blocks are no longer displayed live. #6420 #6657

Merged
merged 2 commits into from
Aug 7, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions web/pgadmin/tools/sqleditor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,9 @@ def poll(trans_id):

if is_thread_alive:
status = 'Busy'
messages = conn.messages()
if messages and len(messages) > 0:
result = ''.join(messages)
elif status and conn is not None and session_obj is not None:
status, result = conn.poll(
formatted_exception_msg=True, no_result=True)
Expand Down
43 changes: 26 additions & 17 deletions web/pgadmin/tools/sqleditor/tests/test_poll_query_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
from regression import parent_node_dict
from regression.python_test_utils import test_utils as utils
import secrets
from pgadmin.tools.sqleditor.tests.execute_query_test_utils \
import async_poll


class TestPollQueryTool(BaseTestGenerator):
Expand Down Expand Up @@ -82,7 +80,6 @@ def runTest(self):
url = '/sqleditor/initialize/sqleditor/{0}/{1}/{2}/{3}'.format(
self.trans_id, utils.SERVER_GROUP, self.server_id, self.db_id)
response = self.tester.post(url)
import time
self.assertEqual(response.status_code, 200)

cnt = 0
Expand All @@ -94,20 +91,32 @@ def runTest(self):
content_type='html/json')

self.assertEqual(response.status_code, 200)

response = async_poll(tester=self.tester,
poll_url='/sqleditor/poll/{0}'.format(
self.trans_id))
self.assertEqual(response.status_code, 200)
response_data = json.loads(response.data.decode('utf-8'))

if self.expected_message[cnt] is not None:
self.assertIn(self.expected_message[cnt],
response_data['data']['additional_messages'])

# Check the output
self.assertEqual(self.expected_result[cnt],
response_data['data']['result'][0][0])
url = '/sqleditor/poll/{0}'.format(self.trans_id)

_status = True
# Lets poll till the status is busy and check the messages
while _status:
response = self.tester.get(url)
if response.data:
response_data = json.loads(response.data.decode('utf-8'))

if response_data['success'] == 1 and 'data' in\
response_data:
if response_data['data']['status'] == 'NotInitialised':
pass
elif response_data['data']['status'] == 'Busy':
if self.expected_message[cnt] is not None:
if response_data['data']['result']:

self.assertIn(
response_data['data']['result'],
self.expected_message[cnt]
)
else:
self.assertEqual(self.expected_result[cnt],
response_data['data']['result'][
0][0])
_status = False

cnt += 1

Expand Down
Loading