fix: clamp count() at 0 when offset exceeds total (#2208)
* fix: clamp count() to limit/offset semantics at the edges COUNT(*) ignores LIMIT/OFFSET, so CountQuery applies them in Python. Two edge cases didn't match the limited query result: - offset greater than the total returned a negative number (e.g. .offset(100).count() == -95 for 5 rows) instead of 0. - limit(0) returned the full total instead of 0, because the limit clamp used a truthiness check (`if self._limit`) that skips 0. Clamp the offset subtraction at 0 and use `self._limit is not None` so an explicit limit(0) is honored. * docs: reference count fix PR in changelog * test: format count edge assertions
P
Parafee41 committed
403a4dce3fca495b12fe493d7dfad9f186d406a2
Parent: 179ea6f
Committed by GitHub <noreply@github.com>
on 5/31/2026, 3:57:05 PM