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

This commit is contained in:
Khushboo Vashi
2023-08-07 17:19:08 +05:30
committed by GitHub
parent 27c7ea2ff1
commit b55164c454
2 changed files with 26 additions and 14 deletions

View File

@@ -927,6 +927,9 @@ def poll(trans_id):
if is_thread_alive: if is_thread_alive:
status = 'Busy' 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: elif status and conn is not None and session_obj is not None:
status, result = conn.poll( status, result = conn.poll(
formatted_exception_msg=True, no_result=True) formatted_exception_msg=True, no_result=True)

View File

@@ -15,8 +15,6 @@ from pgadmin.utils.route import BaseTestGenerator
from regression import parent_node_dict from regression import parent_node_dict
from regression.python_test_utils import test_utils as utils from regression.python_test_utils import test_utils as utils
import secrets import secrets
from pgadmin.tools.sqleditor.tests.execute_query_test_utils \
import async_poll
class TestPollQueryTool(BaseTestGenerator): class TestPollQueryTool(BaseTestGenerator):
@@ -82,7 +80,6 @@ NOTICE: Hello, world!
url = '/sqleditor/initialize/sqleditor/{0}/{1}/{2}/{3}'.format( url = '/sqleditor/initialize/sqleditor/{0}/{1}/{2}/{3}'.format(
self.trans_id, utils.SERVER_GROUP, self.server_id, self.db_id) self.trans_id, utils.SERVER_GROUP, self.server_id, self.db_id)
response = self.tester.post(url) response = self.tester.post(url)
import time
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
cnt = 0 cnt = 0
@@ -94,20 +91,32 @@ NOTICE: Hello, world!
content_type='html/json') content_type='html/json')
self.assertEqual(response.status_code, 200) self.assertEqual(response.status_code, 200)
url = '/sqleditor/poll/{0}'.format(self.trans_id)
response = async_poll(tester=self.tester, _status = True
poll_url='/sqleditor/poll/{0}'.format( # Lets poll till the status is busy and check the messages
self.trans_id)) while _status:
self.assertEqual(response.status_code, 200) response = self.tester.get(url)
response_data = json.loads(response.data.decode('utf-8')) if response.data:
response_data = json.loads(response.data.decode('utf-8'))
if self.expected_message[cnt] is not None: if response_data['success'] == 1 and 'data' in\
self.assertIn(self.expected_message[cnt], response_data:
response_data['data']['additional_messages']) 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']:
# Check the output self.assertIn(
self.assertEqual(self.expected_result[cnt], response_data['data']['result'],
response_data['data']['result'][0][0]) self.expected_message[cnt]
)
else:
self.assertEqual(self.expected_result[cnt],
response_data['data']['result'][
0][0])
_status = False
cnt += 1 cnt += 1