feat: add include_total flag to offset pagination to skip COUNT query (#158)

This commit is contained in:
d3vyce
2026-03-21 15:16:22 +01:00
committed by GitHub
parent 6d6fae5538
commit f8c9bf69fe
6 changed files with 146 additions and 23 deletions

View File

@@ -201,6 +201,27 @@ class TestOffsetPagination:
assert data["page"] == 2
assert data["has_more"] is True
def test_total_count_can_be_none(self):
"""total_count accepts None (include_total=False mode)."""
pagination = OffsetPagination(
total_count=None,
items_per_page=20,
page=1,
has_more=True,
)
assert pagination.total_count is None
def test_serialization_with_none_total_count(self):
"""OffsetPagination serializes total_count=None correctly."""
pagination = OffsetPagination(
total_count=None,
items_per_page=20,
page=1,
has_more=False,
)
data = pagination.model_dump()
assert data["total_count"] is None
class TestCursorPagination:
"""Tests for CursorPagination schema."""