diff --git a/docs/en_US/release_notes_4_2.rst b/docs/en_US/release_notes_4_2.rst index 4182147ed..59f08c84f 100644 --- a/docs/en_US/release_notes_4_2.rst +++ b/docs/en_US/release_notes_4_2.rst @@ -37,6 +37,7 @@ Bug fixes | `Bug #3872 `_ - Ensure object names in external process dialogues are properly escaped. | `Bug #3891 `_ - Correct order of Save and Cancel button for json/jsonb editing. | `Bug #3897 `_ - Data should be updated properly for FTS Configurations, FTS Dictionaries, FTS Parsers and FTS Templates. +| `Bug #3903 `_ - Fixed Query Tool Initialization Error. | `Bug #3908 `_ - Fixed keyboard navigation for Select2 and Privilege cell in Backgrid. | `Bug #3929 `_ - Fix alignment of help messages in properties panels. | `Bug #3935 `_ - Ensure that grant wizard should list down functions for EPAS server running with no-redwood-compat mode. \ No newline at end of file diff --git a/web/pgadmin/tools/datagrid/__init__.py b/web/pgadmin/tools/datagrid/__init__.py index 709e164f5..ded06dec4 100644 --- a/web/pgadmin/tools/datagrid/__init__.py +++ b/web/pgadmin/tools/datagrid/__init__.py @@ -306,8 +306,15 @@ def initialize_query_tool(sgid, sid, did=None): did: Database Id """ connect = True - if ('recreate' in request.args and - request.args['recreate'] == '1'): + reqArgs = None + # Read the data if present. Skipping read may cause connection + # reset error if data is sent from the client + if request.data: + reqArgs = request.data + + reqArgs = request.args + if ('recreate' in reqArgs and + reqArgs['recreate'] == '1'): connect = False # Create asynchronous connection using random connection id. conn_id = str(random.randint(1, 9999999)) diff --git a/web/pgadmin/tools/datagrid/static/js/datagrid.js b/web/pgadmin/tools/datagrid/static/js/datagrid.js index 851d53ff3..ea61dd7ae 100644 --- a/web/pgadmin/tools/datagrid/static/js/datagrid.js +++ b/web/pgadmin/tools/datagrid/static/js/datagrid.js @@ -407,11 +407,20 @@ define('pgadmin.datagrid', [ if (recreate) { baseUrl += '?recreate=1'; } + + /* Send the data only if required. Sending non required data may + * cause connection reset error if data is not read by flask server + */ + let reqData = null; + if(sql_filter != '') { + reqData = JSON.stringify(sql_filter); + } + $.ajax({ url: baseUrl, method: 'POST', dataType: 'json', - data: JSON.stringify(sql_filter), + data: reqData, contentType: 'application/json', }) .done(function(res) { diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index 78d368c92..885d02b9d 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -96,7 +96,6 @@ define('tools.querytool', [ 'click #btn-include-filter': 'on_include_filter', 'click #btn-exclude-filter': 'on_exclude_filter', 'click #btn-remove-filter': 'on_remove_filter', - 'click #btn-apply': 'on_apply', 'click #btn-cancel': 'on_cancel', 'click #btn-copy-row': 'on_copy_row', 'click #btn-paste-row': 'on_paste_row', @@ -1475,18 +1474,6 @@ define('tools.querytool', [ ); }, - // Callback function for ok button click. - on_apply: function() { - var self = this; - - // Trigger the apply_filter signal to the SqlEditorController class - self.handler.trigger( - 'pgadmin-sqleditor:button:apply_filter', - self, - self.handler - ); - }, - // Callback function for cancel button click. on_cancel: function() { $('#filter').addClass('d-none'); @@ -2084,7 +2071,6 @@ define('tools.querytool', [ self.on('pgadmin-sqleditor:button:include_filter', self._include_filter, self); self.on('pgadmin-sqleditor:button:exclude_filter', self._exclude_filter, self); self.on('pgadmin-sqleditor:button:remove_filter', self._remove_filter, self); - self.on('pgadmin-sqleditor:button:apply_filter', self._apply_filter, self); self.on('pgadmin-sqleditor:button:copy_row', self._copy_row, self); self.on('pgadmin-sqleditor:button:paste_row', self._paste_row, self); self.on('pgadmin-sqleditor:button:limit', self._set_limit, self); @@ -3264,49 +3250,6 @@ define('tools.querytool', [ }); }, - // This function will apply the filter. - _apply_filter: function() { - var self = this, - sql = self.gridView.filter_obj.getValue(); - - self.trigger( - 'pgadmin-sqleditor:loading-icon:show', - gettext('Applying the filter...') - ); - - // Make ajax call to include the filter by selection - $.ajax({ - url: url_for('sqleditor.apply_filter', { - 'trans_id': self.transId, - }), - method: 'POST', - contentType: 'application/json', - data: JSON.stringify(sql), - }) - .done(function(res) { - self.trigger('pgadmin-sqleditor:loading-icon:hide'); - setTimeout( - function() { - if (res.data.status) { - $('#filter').addClass('d-none'); - $('#editor-panel').removeClass('sql-editor-busy-fetching'); - // Refresh the sql grid - queryToolActions.executeQuery(self); - } else { - alertify.alert(gettext('Apply Filter Error'), res.data.result); - } - }, 10 - ); - }) - .fail(function(e) { - self.trigger('pgadmin-sqleditor:loading-icon:hide'); - let msg = httpErrorHandler.handleQueryToolAjaxError( - pgAdmin, self, e, '_apply_filter', [], true - ); - alertify.alert(gettext('Apply Filter Error'), msg); - }); - }, - // This function will copy the selected row. _copy_row: copyData,