public inbox for [email protected]
help / color / mirror / Atom feed[pgAdmin][RM4263] "Not connected to the server or the connection to the server has been closed." returned with some queries
2+ messages / 2 participants
[nested] [flat]
* [pgAdmin][RM4263] "Not connected to the server or the connection to the server has been closed." returned with some queries
@ 2019-05-22 05:11 Aditya Toshniwal <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Aditya Toshniwal @ 2019-05-22 05:11 UTC (permalink / raw)
To: pgadmin-hackers
Hi Hackers,
Attached is the quick fix for the issue. The problem was with parsing
failure of JSON result in explain plan code. I have added an api test case
to check length of result format to match with JS code expectations for
explain plan.
Kindly review.
--
Thanks and Regards,
Aditya Toshniwal
Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"
Attachments:
[application/octet-stream] RM4263.patch (3.7K, 3-RM4263.patch)
download | inline diff:
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index fcc31cf3..41458445 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -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] &&
diff --git a/web/pgadmin/tools/sqleditor/tests/test_explain_plan.py b/web/pgadmin/tools/sqleditor/tests/test_explain_plan.py
new file mode 100644
index 00000000..9f9d1384
--- /dev/null
+++ b/web/pgadmin/tools/sqleditor/tests/test_explain_plan.py
@@ -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)
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: [pgAdmin][RM4263] "Not connected to the server or the connection to the server has been closed." returned with some queries
@ 2019-05-23 07:53 Dave Page <[email protected]>
parent: Aditya Toshniwal <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Dave Page @ 2019-05-23 07:53 UTC (permalink / raw)
To: Aditya Toshniwal <[email protected]>; +Cc: pgadmin-hackers
Thanks, applied.
On Wed, May 22, 2019 at 6:12 AM Aditya Toshniwal <
[email protected]> wrote:
> Hi Hackers,
>
> Attached is the quick fix for the issue. The problem was with parsing
> failure of JSON result in explain plan code. I have added an api test case
> to check length of result format to match with JS code expectations for
> explain plan.
>
> Kindly review.
> --
> Thanks and Regards,
> Aditya Toshniwal
> Software Engineer | EnterpriseDB India | Pune
> "Don't Complain about Heat, Plant a TREE"
>
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2019-05-23 07:53 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-05-22 05:11 [pgAdmin][RM4263] "Not connected to the server or the connection to the server has been closed." returned with some queries Aditya Toshniwal <[email protected]>
2019-05-23 07:53 ` Dave Page <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox