diff --git a/docs/en_US/release_notes_4_21.rst b/docs/en_US/release_notes_4_21.rst index a4196db87..d0d3b4f04 100644 --- a/docs/en_US/release_notes_4_21.rst +++ b/docs/en_US/release_notes_4_21.rst @@ -29,7 +29,6 @@ Bug fixes | `Issue #1257 `_ - Ensure all object types have a "System XXX?" property. | `Issue #2813 `_ - Ensure that the password prompt should not be visible if the database server is in trust authentication mode. -| `Issue #3269 `_ - Fixed an issue where slider jumps up when new rows get loaded while scrolling down in the DataView panel in the query tool. | `Issue #3495 `_ - Fixed an issue where the query tool unable to load the file which contains the BOM marker. | `Issue #3523 `_ - Fixed an issue where right-clicking a browser object does not apply to the object on which right-click was fired. | `Issue #3645 `_ - Ensure that the start and end date should be deleted when clear the selection for pgAgent Job. @@ -86,4 +85,4 @@ Bug fixes | `Issue #5415 `_ - Ensure that the query tool context menu should work on the collection nodes. | `Issue #5419 `_ - Ensure that the user should not be able to change the authentication source. | `Issue #5420 `_ - Ensure error should be handled properly when LDAP user is created with the same name. -| `Issue #5432 `_ - Fixed an issue where an internal user is not created if the authentication source is set to internal and ldap. \ No newline at end of file +| `Issue #5432 `_ - Fixed an issue where an internal user is not created if the authentication source is set to internal and ldap. diff --git a/web/pgadmin/tools/sqleditor/__init__.py b/web/pgadmin/tools/sqleditor/__init__.py index 88bc3c959..658f091a1 100644 --- a/web/pgadmin/tools/sqleditor/__init__.py +++ b/web/pgadmin/tools/sqleditor/__init__.py @@ -97,7 +97,6 @@ class SqlEditorModule(PgAdminModule): 'sqleditor.query_tool_start', 'sqleditor.poll', 'sqleditor.fetch', - 'sqleditor.fetch_till', 'sqleditor.fetch_all', 'sqleditor.save', 'sqleditor.inclusive_filter', @@ -534,24 +533,18 @@ def poll(trans_id): '/fetch//', methods=["GET"], endpoint='fetch_all' ) -@blueprint.route( - '/fetch//', methods=["GET"], - endpoint='fetch_till' -) @login_required -def fetch(trans_id, fetch_all=None, fetch_till=None): +def fetch(trans_id, fetch_all=None): result = None has_more_rows = False rows_fetched_from = 0 rows_fetched_to = 0 + fetch_row_cnt = -1 if fetch_all == 1 else ON_DEMAND_RECORD_COUNT # Check the transaction and connection status status, error_msg, conn, trans_obj, session_obj = \ check_transaction_status(trans_id) - fetch_row_cnt = -1 if fetch_all == 1 else ON_DEMAND_RECORD_COUNT \ - if fetch_till is None else fetch_till - trans_obj.get_fetched_row_cnt() - if error_msg == gettext('Transaction ID not found in the session.'): return make_json_response(success=0, errormsg=error_msg, info='DATAGRID_TRANSACTION_REQUIRED', @@ -564,6 +557,8 @@ def fetch(trans_id, fetch_all=None, fetch_till=None): else: status = 'Success' res_len = len(result) + if fetch_row_cnt != -1 and res_len == ON_DEMAND_RECORD_COUNT: + has_more_rows = True if res_len: rows_fetched_from = trans_obj.get_fetched_row_cnt() @@ -572,9 +567,6 @@ def fetch(trans_id, fetch_all=None, fetch_till=None): rows_fetched_to = trans_obj.get_fetched_row_cnt() session_obj['command_obj'] = pickle.dumps(trans_obj, -1) update_session_grid_transaction(trans_id, session_obj) - - if fetch_row_cnt != -1 and rows_fetched_to < conn.rows_affected(): - has_more_rows = True else: status = 'NotConnected' result = error_msg diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js index e0a6c99b4..a0c4d1d19 100644 --- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js +++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js @@ -737,12 +737,6 @@ 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) { - if (rows_affected) { - let dummyCollection = new Array(rows_affected - collection.length); - // Adding dummy rows to adjust height, rows data will be update as and when user scrolls down in DataView panel - dummyCollection.fill([gettext('Loading...')]); - collection = [...collection, ...dummyCollection]; - } var self = this; self.handler.numberOfModifiedCells = 0; @@ -1212,18 +1206,13 @@ define('tools.querytool', [ $('#btn-save-data').prop('disabled', false); }.bind(editor_data)); - grid.onScroll.subscribe((e, args) => { - clearTimeout($.data(this, 'scrollTimer')); - $.data(this, 'scrollTimer', setTimeout(function () { - if (self.handler.has_more_rows && !self.handler.fetching_rows && args.grid.getViewport().bottom > self.handler.rows_fetched_to + self.handler.rows_fetch_batch_count) { - // fast scrolling using slider - let fetch_till = (parseInt(args.grid.getViewport().bottom / self.handler.rows_fetch_batch_count) + 1) * self.handler.rows_fetch_batch_count; - self.fetch_next(null, null, fetch_till); - } - }, 250)); - // If its gentle scroll, when last 10% of rows are left to scroll then fetch next batch of rows - if (self.handler.has_more_rows && !self.handler.fetching_rows && args.grid.getViewport().bottom + (self.handler.rows_fetch_batch_count * 0.1) > self.handler.rows_fetched_to) { - // gentle scroll using mouse + // Listen grid viewportChanged event to load next chunk of data. + grid.onViewportChanged.subscribe(function(e, args) { + var rendered_range = args.grid.getRenderedRange(), + data_len = args.grid.getDataLength(); + // start fetching next batch of records before reaching to bottom. + if (self.handler.has_more_rows && !self.handler.fetching_rows && rendered_range.bottom > data_len - 100) { + // fetch asynchronous setTimeout(self.fetch_next.bind(self)); } }); @@ -1272,7 +1261,7 @@ define('tools.querytool', [ this.fetch_next(true, cb); }, - fetch_next: function(fetch_all, cb, fetch_till) { + fetch_next: function(fetch_all, cb) { var self = this, url = ''; @@ -1293,18 +1282,11 @@ define('tools.querytool', [ 'fetch_all': 1, }); } else { - if (fetch_till) { - url = url_for('sqleditor.fetch_till', { - 'trans_id': self.transId, - fetch_till: fetch_till, - }); - } else { - url = url_for('sqleditor.fetch', { - 'trans_id': self.transId, - }); - } + url = url_for('sqleditor.fetch', { + 'trans_id': self.transId, + }); } - self.handler.last_rows_fetched_to = self.handler.rows_fetched_to; + $.ajax({ url: url, method: 'GET', @@ -1314,8 +1296,7 @@ define('tools.querytool', [ $('#btn-flash').prop('disabled', false); $('#btn-download').prop('disabled', false); self.handler.trigger('pgadmin-sqleditor:loading-icon:hide'); - self.handler.rows_fetched_to = res.data.rows_fetched_to; - setTimeout(() => self.update_grid_data(res.data.result), 100); + self.update_grid_data(res.data.result); self.handler.fetching_rows = false; if (typeof cb == 'function') { cb(); @@ -1341,15 +1322,16 @@ define('tools.querytool', [ update_grid_data: function(data) { this.dataView.beginUpdate(); - for (var i = 0, k = this.handler.last_rows_fetched_to; k < this.handler.rows_fetched_to; i++ , k++) { + + for (var i = 0; i < data.length; i++) { // Convert 2darray to dict. var item = {}; for (var j = 1; j < this.grid_columns.length; j++) { item[this.grid_columns[j]['field']] = data[i][this.grid_columns[j]['pos']]; } - item['__temp_PK'] = k; - this.dataView.updateItem(k, item); + item[this.client_primary_key] = (this.client_primary_key_counter++).toString(); + this.dataView.addItem(item); } this.dataView.endUpdate(); @@ -2246,7 +2228,6 @@ define('tools.querytool', [ self.marked_line_no = 0; self.has_more_rows = false; self.fetching_rows = false; - self.rows_fetched_to = 0; self.close_on_save = false; self.close_on_idle_transaction = false; self.last_transaction_status = -1; @@ -2693,8 +2674,6 @@ define('tools.querytool', [ // Make sure - the 'Data Output' panel is visible, before - we // start rendering the grid. self.gridView.data_output_panel.focus(); - self.gridView.handler.rows_fetched_to = data.rows_fetched_to; - self.gridView.handler.rows_fetch_batch_count = data.rows_fetched_to - (data.rows_fetched_from - 1); setTimeout( function() { self.gridView.render_grid(data.result, self.columns,