mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
If max_returned_rows==page_size, increment max_returned_rows
Fixes #230, where if the two were equal pagination didn't work correctly.
This commit is contained in:
parent
02ee31c8b4
commit
4504d5160b
3 changed files with 28 additions and 6 deletions
|
|
@ -176,10 +176,13 @@ class BaseView(RenderMixin):
|
|||
try:
|
||||
cursor = conn.cursor()
|
||||
cursor.execute(sql, params or {})
|
||||
if self.max_returned_rows and truncate:
|
||||
rows = cursor.fetchmany(self.max_returned_rows + 1)
|
||||
truncated = len(rows) > self.max_returned_rows
|
||||
rows = rows[:self.max_returned_rows]
|
||||
max_returned_rows = self.max_returned_rows
|
||||
if max_returned_rows == self.page_size:
|
||||
max_returned_rows += 1
|
||||
if max_returned_rows and truncate:
|
||||
rows = cursor.fetchmany(max_returned_rows + 1)
|
||||
truncated = len(rows) > max_returned_rows
|
||||
rows = rows[:max_returned_rows]
|
||||
else:
|
||||
rows = cursor.fetchall()
|
||||
truncated = False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue