mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-24 07:16:52 -06:00
Fix handling of JSON in the Query Tool with NULL elements. Fixes #4263
This commit is contained in:
parent
f1ef7b0346
commit
ee37be56f9
@ -24,6 +24,7 @@ Bug fixes
|
||||
| `Bug #4246 <https://redmine.postgresql.org/issues/4246>`_ - Fixed console error when subnode control is used in panels.
|
||||
| `Bug #4261 <https://redmine.postgresql.org/issues/4261>`_ - Stop using application/x-javascript as a mime type and use the RFC-compliant application/javascript instead.
|
||||
| `Bug #4262 <https://redmine.postgresql.org/issues/4262>`_ - Fixed error on displaying table properties of a table partitioned by list having a default partition.
|
||||
| `Bug #4263 <https://redmine.postgresql.org/issues/4263>`_ - Fix handling of JSON in the Query Tool with NULL elements.
|
||||
| `Bug #4269 <https://redmine.postgresql.org/issues/4269>`_ - Fix navigation of switch cells in grids.
|
||||
| `Bug #4275 <https://redmine.postgresql.org/issues/4275>`_ - Clarify wording for the NO INHERIT option on constraints, per Michel Feinstein.
|
||||
| `Bug #4276 <https://redmine.postgresql.org/issues/4276>`_ - Relax the permission check on the directory containing the config database, as it may fail in some environments such as OpenShift.
|
||||
|
@ -2424,7 +2424,7 @@ define('tools.querytool', [
|
||||
|
||||
if(data.types[0] && data.types[0].typname === 'json') {
|
||||
/* json is sent as text, parse it */
|
||||
explain_data_json = JSON.parse(data.result[0]);
|
||||
explain_data_json = JSON.parse(data.result[0][0]);
|
||||
}
|
||||
|
||||
if (explain_data_json && explain_data_json[0] &&
|
||||
|
72
web/pgadmin/tools/sqleditor/tests/test_explain_plan.py
Normal file
72
web/pgadmin/tools/sqleditor/tests/test_explain_plan.py
Normal file
@ -0,0 +1,72 @@
|
||||
##########################################################################
|
||||
#
|
||||
# pgAdmin 4 - PostgreSQL Tools
|
||||
#
|
||||
# Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
||||
# This software is released under the PostgreSQL Licence
|
||||
#
|
||||
##########################################################################
|
||||
|
||||
import json
|
||||
|
||||
from pgadmin.browser.server_groups.servers.databases.tests import utils as \
|
||||
database_utils
|
||||
from pgadmin.utils.route import BaseTestGenerator
|
||||
from regression import parent_node_dict
|
||||
from regression.python_test_utils import test_utils as utils
|
||||
|
||||
|
||||
class TestExplainPlan(BaseTestGenerator):
|
||||
""" This class will test the explain plan return format. """
|
||||
|
||||
def runTest(self):
|
||||
database_info = parent_node_dict["database"][-1]
|
||||
self.server_id = database_info["server_id"]
|
||||
|
||||
self.db_id = database_info["db_id"]
|
||||
db_con = database_utils.connect_database(self,
|
||||
utils.SERVER_GROUP,
|
||||
self.server_id,
|
||||
self.db_id)
|
||||
if not db_con["info"] == "Database connected.":
|
||||
raise Exception("Could not connect to the database.")
|
||||
|
||||
# Initialize query tool
|
||||
url = '/datagrid/initialize/query_tool/{0}/{1}/{2}'.format(
|
||||
utils.SERVER_GROUP, self.server_id, self.db_id)
|
||||
response = self.tester.post(url)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
|
||||
response_data = json.loads(response.data.decode('utf-8'))
|
||||
self.trans_id = response_data['data']['gridTransId']
|
||||
|
||||
# Start query tool transaction
|
||||
url = '/sqleditor/query_tool/start/{0}'.format(self.trans_id)
|
||||
response = self.tester.post(
|
||||
url, data=json.dumps({
|
||||
"sql": "SELECT 1",
|
||||
"explain_plan": {
|
||||
"format": "json",
|
||||
"analyze": False,
|
||||
"verbose": False,
|
||||
"costs": False,
|
||||
"buffers": False,
|
||||
"timing": False,
|
||||
"verbose": False
|
||||
}
|
||||
}), content_type='html/json')
|
||||
|
||||
self.assertEquals(response.status_code, 200)
|
||||
|
||||
# Query tool polling
|
||||
url = '/sqleditor/poll/{0}'.format(self.trans_id)
|
||||
response = self.tester.get(url)
|
||||
self.assertEquals(response.status_code, 200)
|
||||
response_data = json.loads(response.data.decode('utf-8'))
|
||||
|
||||
# Check the ouput of explain plan
|
||||
self.assertEquals(len(response_data['data']['result']), 1)
|
||||
self.assertEquals(len(response_data['data']['result'][0]), 1)
|
||||
|
||||
# Disconnect the database
|
||||
database_utils.disconnect_database(self, self.server_id, self.db_id)
|
Loading…
Reference in New Issue
Block a user