Skip to content

Commit

Permalink
WCM-22: Offset query results for pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
louika committed Sep 5, 2024
1 parent 227920e commit 26bc612
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions core/src/zeit/content/cp/tests/test_automatic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1149,3 +1149,8 @@ def test_set_query_order(self):
def test_limit_query_results(self):
IRenderedArea(self.area).values()
self.assertEllipsis('...LIMIT 3...', self.connector.search_args[0])

def test_offset_query_results_for_pagination(self):
self.area.start = 5
IRenderedArea(self.area).values()
self.assertEllipsis('...OFFSET 5...', self.connector.search_args[0])
2 changes: 1 addition & 1 deletion core/src/zeit/contentquery/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def _build_query(self):
query = self.add_clauses(query)
query = self.hide_dupes_clause(query)
query = query.order_by(sql(self.context.sql_order))
query = query.limit(self.rows)
query = query.limit(self.rows).offset(self.start)

return query

Expand Down

0 comments on commit 26bc612

Please sign in to comment.