public inbox for [email protected]
help / color / mirror / Atom feedFrom: Khushboo Vashi <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: [pgAdmin4][Patch] - RM 4427 , RM 4484, RM 4485
Date: Mon, 22 Jul 2019 15:50:45 +0530
Message-ID: <CAFOhELfJxWN71c3vryv_fgurb2uw8L88CbJVcJuJBU_2dR2g5A@mail.gmail.com> (raw)
Hi,
Please find the attached patch to fix below RMs:
#4427 - Cannot View Retrieve Records From 1 Table
#4484 - Query Tool - Explain & Explain Analyze are broken
#4485 - View Data - Filter Data is broken
This issues are the regression of below commits:
74cfeabd02c8fd63d2604ac826dae7ed4308a91e
710d520631b1b4649eb4a8d924e3141ff74af449
4cbc1f2f59192f6461cfeea96aec2d3ee5df5f06
Thanks,
Khushboo
Attachments:
[application/octet-stream] RM_4427_4484_4485.patch (10.3K, 3-RM_4427_4484_4485.patch)
download | inline diff:
diff --git a/web/pgadmin/static/js/backform.pgadmin.js b/web/pgadmin/static/js/backform.pgadmin.js
index 156430df..012a7432 100644
--- a/web/pgadmin/static/js/backform.pgadmin.js
+++ b/web/pgadmin/static/js/backform.pgadmin.js
@@ -1271,12 +1271,19 @@ define([
var $dialog = gridBody.append(subNodeGrid);
- let preferences = pgBrowser.get_preferences_for_module('browser');
- let addBtn = $dialog.find('.add');
- // Add title to the buttons
- $(addBtn)
- .attr('title',
- keyboardShortcuts.shortcut_title(gettext('Add new row'),preferences.add_grid_row));
+ let tmp_browser = pgBrowser;
+ if (pgBrowser.preferences_cache.length == 0)
+ tmp_browser = window.opener ? window.opener.pgAdmin.Browser : window.top.pgAdmin.Browser;
+
+ let preferences = tmp_browser.get_preferences_for_module('browser');
+
+ if (preferences) {
+ let addBtn = $dialog.find('.add');
+ // Add title to the buttons
+ $(addBtn)
+ .attr('title',
+ keyboardShortcuts.shortcut_title(gettext('Add new row'),preferences.add_grid_row));
+ }
// Add button callback
if (!(data.disabled || data.canAdd == false)) {
@@ -1563,12 +1570,19 @@ define([
var $dialog = gridBody.append(subNodeGrid);
- let preferences = pgBrowser.get_preferences_for_module('browser');
- let addBtn = $dialog.find('.add');
- // Add title to the buttons
- $(addBtn)
- .attr('title',
- keyboardShortcuts.shortcut_title(gettext('Add new row'),preferences.add_grid_row));
+ let tmp_browser = pgBrowser;
+ if (pgBrowser.preferences_cache.length == 0)
+ tmp_browser = window.opener ? window.opener.pgAdmin.Browser : window.top.pgAdmin.Browser;
+
+ let preferences = tmp_browser.get_preferences_for_module('browser');
+
+ if (preferences) {
+ let addBtn = $dialog.find('.add');
+ // Add title to the buttons
+ $(addBtn)
+ .attr('title',
+ keyboardShortcuts.shortcut_title(gettext('Add new row'),preferences.add_grid_row));
+ }
// Add button callback
diff --git a/web/pgadmin/static/js/sqleditor/call_render_after_poll.js b/web/pgadmin/static/js/sqleditor/call_render_after_poll.js
index 57d60537..ec18b10b 100644
--- a/web/pgadmin/static/js/sqleditor/call_render_after_poll.js
+++ b/web/pgadmin/static/js/sqleditor/call_render_after_poll.js
@@ -36,7 +36,10 @@ export function callRenderAfterPoll(sqlEditor, alertify, res) {
sqlEditor.query_end_time);
const msg = sprintf(
gettext('Query returned successfully in %s.'), sqlEditor.total_time);
- res.result += '\n\n' + msg;
+ if (res.result)
+ res.result += '\n\n' + msg;
+ else
+ res.result = msg;
sqlEditor.update_msg_history(true, res.result, true);
sqlEditor.reset_data_store();
if (isNotificationEnabled(sqlEditor)) {
diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py
index 851e3f36..d7435702 100644
--- a/web/pgadmin/tools/sqleditor/__init__.py
+++ b/web/pgadmin/tools/sqleditor/__init__.py
@@ -407,6 +407,8 @@ def poll(trans_id):
if (result != 'SELECT 1' or result != 'SELECT 0') and \
result is not None and additional_messages:
result = additional_messages + result
+ else:
+ result = None
if st:
if 'primary_keys' in session_obj:
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 5d734da5..21734410 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -705,7 +705,7 @@ define('tools.querytool', [
*/
// This function is responsible to create and render the SlickGrid.
- render_grid: function(collection, columns, is_editable, client_primary_key, rows_affected) {
+ render_grid: function(collection, columns, is_editable, client_primary_key, rows_affected, is_explain_plan) {
var self = this;
self.handler.numberOfModifiedCells = 0;
@@ -824,7 +824,7 @@ define('tools.querytool', [
}
var grid_options = {
- editable: is_editable,
+ editable: is_editable || is_explain_plan,
enableAddRow: is_editable,
enableCellNavigation: true,
enableColumnReorder: false,
@@ -2379,7 +2379,7 @@ define('tools.querytool', [
*/
_render: function(data) {
var self = this;
- self.colinfo = data.col_info;
+ self.colinfo = data.colinfo;
self.primary_keys = (_.isEmpty(data.primary_keys) && data.has_oids) ? data.oids : data.primary_keys;
self.client_primary_key = data.client_primary_key;
self.cell_selected = false;
@@ -2388,6 +2388,7 @@ define('tools.querytool', [
self.has_oids = data.has_oids;
self.oids = data.oids;
$('.sql-editor-explain').empty();
+ self.explain_plan = false;
/* If object don't have primary keys then set the
* can_edit flag to false.
@@ -2463,9 +2464,12 @@ define('tools.querytool', [
var explain_data_array = [],
explain_data_json = null;
- if(data.types[0] && data.types[0].typname === 'json') {
+
+ if(self.colinfo[0].name == 'QUERY PLAN' && data.result
+ && data.types[0] && data.types[0].typname === 'json') {
/* json is sent as text, parse it */
explain_data_json = JSON.parse(data.result[0][0]);
+ self.is_explain_plan = true;
}
if (explain_data_json && explain_data_json[0] &&
@@ -2481,7 +2485,7 @@ define('tools.querytool', [
function() {
self.gridView.render_grid(
explain_data_array, self.columns, self.can_edit,
- self.client_primary_key
+ self.client_primary_key, 0, self.is_explain_plan
);
// Make sure - the 'Explain' panel is visible, before - we
// start rendering the grid.
diff --git a/web/pgadmin/tools/sqleditor/tests/test_save_changed_data.py b/web/pgadmin/tools/sqleditor/tests/test_save_changed_data.py
index badf1c61..29e9cce3 100644
--- a/web/pgadmin/tools/sqleditor/tests/test_save_changed_data.py
+++ b/web/pgadmin/tools/sqleditor/tests/test_save_changed_data.py
@@ -251,7 +251,7 @@ class TestSaveChangedData(BaseTestGenerator):
},
save_status=True,
check_sql='SELECT * FROM %s WHERE pk_col = 2',
- check_result='SELECT 0'
+ check_result=None
)),
]
diff --git a/web/pgadmin/tools/sqleditor/tests/test_view_data.py b/web/pgadmin/tools/sqleditor/tests/test_view_data.py
new file mode 100644
index 00000000..dc96f9cd
--- /dev/null
+++ b/web/pgadmin/tools/sqleditor/tests/test_view_data.py
@@ -0,0 +1,98 @@
+##########################################################################
+#
+# pgAdmin 4 - PostgreSQL Tools
+#
+# Copyright (C) 2013 - 2019, The pgAdmin Development Team
+# This software is released under the PostgreSQL Licence
+#
+##########################################################################
+
+import uuid
+import json
+import random
+
+from pgadmin.utils.route import BaseTestGenerator
+from pgadmin.browser.server_groups.servers.databases.tests import utils as \
+ database_utils
+from regression import parent_node_dict
+from regression.python_test_utils import test_utils
+from pgadmin.utils import server_utils, IS_PY2
+
+
+class TestViewData(BaseTestGenerator):
+ """
+ This class checks the view data result for a table with JSON datatype
+ """
+ skip_on_database = ['gpdb']
+ scenarios = [
+ (
+ 'Table with JSON datatype',
+ dict(
+ table_sql="""Create Table <TABLE_NAME>(
+ id integer Not Null,
+ json_val json Not Null,
+ Constraint table_pk Primary Key(id)
+ );""",
+ result_data=None,
+ rows_fetched_to=0
+ )
+ )
+ ]
+
+ def setUp(self):
+ self.server_id = self.server_information['server_id']
+ self.database_info = parent_node_dict["database"][-1]
+ self.db_name = self.database_info["db_name"]
+ self.db_id = self.database_info["db_id"]
+
+ self.connection = test_utils.get_db_connection(
+ self.db_name,
+ self.server['username'],
+ self.server['db_password'],
+ self.server['host'],
+ self.server['port']
+ )
+
+ def runTest(self):
+ self.table = "test_table_%s" % (str(uuid.uuid4())[1:8])
+ self.table_sql = self.table_sql.replace('<TABLE_NAME>', self.table)
+ # Create table
+ test_utils.create_table_with_query(self.server,
+ self.db_name,
+ self.table_sql)
+
+ # Fetch Table OID
+ pg_cursor = self.connection.cursor()
+ pg_cursor.execute("""Select oid FROM pg_class WHERE
+ relname = '%s' AND relkind IN ('r','s','t')""" % self.table)
+
+ result = pg_cursor.fetchall()
+ table_id = result[0][0]
+
+ # Initialize query tool
+ url = '/datagrid/initialize/datagrid/3/table/{0}/{1}/{2}/{3}'.format(
+ test_utils.SERVER_GROUP, self.server_id, self.db_id, table_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']
+
+ url = "/sqleditor/view_data/start/{0}".format(self.trans_id)
+ response = self.tester.get(url)
+ self.assertEquals(response.status_code, 200)
+
+ # Check the query result
+ 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'))
+
+ self.assertEquals(response_data['data']['result'], self.result_data)
+ self.assertEquals(response_data['data']['rows_fetched_to'],
+ self.rows_fetched_to)
+
+ def tearDown(self):
+ database_utils.disconnect_database(self, self.server_id,
+ self.db_id)
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [pgAdmin4][Patch] - RM 4427 , RM 4484, RM 4485
In-Reply-To: <CAFOhELfJxWN71c3vryv_fgurb2uw8L88CbJVcJuJBU_2dR2g5A@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox