mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Replace infinite scrolling with pagination in query tool data output for better UX and performance. #1780
This commit is contained in:
@@ -1308,6 +1308,7 @@ WHERE db.datname = current_database()""")
|
||||
return True, {'columns': columns, 'rows': rows}
|
||||
|
||||
def async_fetchmany_2darray(self, records=2000,
|
||||
from_rownum=0, to_rownum=0,
|
||||
formatted_exception_msg=False):
|
||||
"""
|
||||
User should poll and check if status is ASYNC_OK before calling this
|
||||
@@ -1342,6 +1343,10 @@ WHERE db.datname = current_database()""")
|
||||
try:
|
||||
if records == -1:
|
||||
result = cur.fetchall(_tupples=True)
|
||||
elif records is None:
|
||||
result = cur.fetchwindow(from_rownum=from_rownum,
|
||||
to_rownum=to_rownum,
|
||||
_tupples=True)
|
||||
else:
|
||||
result = cur.fetchmany(records, _tupples=True)
|
||||
except psycopg.ProgrammingError:
|
||||
@@ -1538,6 +1543,12 @@ Failed to reset the connection to the server due to following error:
|
||||
|
||||
return self.row_count
|
||||
|
||||
@property
|
||||
def total_rows(self):
|
||||
if self.__async_cursor is None:
|
||||
return 0
|
||||
return self.__async_cursor.rowcount
|
||||
|
||||
def get_column_info(self):
|
||||
"""
|
||||
This function will returns list of columns for last async sql command
|
||||
|
||||
@@ -364,6 +364,20 @@ class AsyncDictCursor(_async_cursor):
|
||||
self.row_factory = dict_row
|
||||
return res
|
||||
|
||||
def fetchwindow(self, from_rownum=0, to_rownum=0, _tupples=False):
|
||||
"""
|
||||
Fetch many tuples as ordered dictionary list.
|
||||
"""
|
||||
self._odt_desc = None
|
||||
self.row_factory = tuple_row
|
||||
asyncio.run(self._scrollcur(from_rownum, "absolute"))
|
||||
res = asyncio.run(self._fetchmany(to_rownum - from_rownum + 1))
|
||||
if not _tupples and res is not None:
|
||||
res = [self._dict_tuple(t) for t in res]
|
||||
|
||||
self.row_factory = dict_row
|
||||
return res
|
||||
|
||||
async def _scrollcur(self, position, mode):
|
||||
"""
|
||||
Fetch all tuples as ordered dictionary list.
|
||||
|
||||
Reference in New Issue
Block a user