Fix incorrect next-page offset calculation#115
Conversation
pCtx.Offset is already a row offset, not a page number. The previous formula `pCtx.Offset * pageSize + pageSize` treated it as a page index, causing the offset to jump from 200 to 10100 after the second page (with pageSize=100), which broke pagination beyond 200 records. The correct formula is simply `pCtx.Offset + pageSize`. Fixes CXH-1261
|
Claude finished @c1-dev-bot[bot]'s task in 53s —— View job PR Review: Fix incorrect next-page offset calculation
Verdict: Approve ✅ The fix is correct. Here's the trace confirming the bug and the fix: In offset, err := strconv.ParseInt(pToken.Token, 10, 64)
ret.Offset = offset // This IS a row offset, not a page numberBefore (broken):
After (fixed):
The old formula would have been correct if One observation: There are no unit tests covering Overall this is a clean, minimal one-line fix for a real bug. LGTM. |
Summary
pkg/bsql/query.gowherepCtx.Offsetwas incorrectly treated as a page number instead of a row offsetpCtx.Offset * pageSize + pageSizetopCtx.Offset + pageSizeTest plan
go test ./...)Fixes CXH-1261