Fix pagination issues in the query tool data output when using a server-side cursor.

pull/8973/head
Khushboo Vashi 2025-07-18 17:54:06 +05:30 committed by GitHub
parent 6fdb82dd76
commit ea085cd009
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 5 deletions

View File

@ -1080,7 +1080,10 @@ def poll(trans_id):
rows_affected = conn.rows_affected()
st, result = \
conn.async_fetchmany_2darray(data_result_rows_per_page)
conn.async_fetchmany_2darray(data_result_rows_per_page + 1
if trans_obj.server_cursor
else data_result_rows_per_page
)
# There may be additional messages even if result is present
# eg: Function can provide result as well as RAISE messages
@ -1201,12 +1204,22 @@ def poll(trans_id):
if trans_obj is not None and hasattr(trans_obj, 'did') else 0
page_size = rows_fetched_to - rows_fetched_from + 1
# Check the next recordset/page is available or not for the server cursor
next_page = 0
if (trans_obj.server_cursor and result and len(result) > 0 and
len(result) > data_result_rows_per_page):
result = result[0:len(result) - 1]
next_page = 1
rows_fetched_to = rows_fetched_to - 1
pagination = {
'page_size': page_size,
'page_count': math.ceil(conn.total_rows / page_size),
'page_no': math.floor((rows_fetched_from - 1) / page_size) + 1,
'rows_from': rows_fetched_from,
'rows_to': rows_fetched_to
'rows_to': rows_fetched_to,
'next_page': next_page
}
return make_json_response(
@ -1275,7 +1288,7 @@ def fetch_window(trans_id, from_rownum=0, to_rownum=0):
page_size = to_rownum - from_rownum + 1
# Check whether the next recordset/page is available or not
# Check the next recordset/page is available or not for the server cursor
next_page = 0
if trans_obj.server_cursor and len(result) > 0 and len(result) > page_size:
result = result[0:len(result) - 1]

View File

@ -401,8 +401,8 @@ class AsyncDictServerCursor(AsyncDictCursor, _async_server_cursor):
def __init__(self, *args, name=None, **kwargs):
self._odt_desc = None
_async_server_cursor.__init__(self, name=name, *args,
row_factory=dict_row)
kwargs['row_factory'] = dict_row
_async_server_cursor.__init__(self, name=name, *args, **kwargs)
self.cursor = _async_server_cursor
def get_rowcount(self):