Skip to content

fix: RangeResult limit=0 returns empty result instead of ambiguous batch (#51) - #59

Merged
s2x merged 1 commit into
masterfrom
fix/issue-51-range-limit-zero
Jul 3, 2026
Merged

fix: RangeResult limit=0 returns empty result instead of ambiguous batch (#51)#59
s2x merged 1 commit into
masterfrom
fix/issue-51-range-limit-zero

Conversation

@s2x

@s2x s2x commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Closes #51

Problem: RangeResult treated limit: 0 as "unlimited" for the first batch (because FoundationDB C API interprets 0 as unlimited), then broke immediately because fetched (0) >= limit (0). This produced an ambiguous single-batch result.

Fix: Added an early return in getIterator() when $limit === 0, so the generator yields zero rows immediately. limit: null remains the way to request all matching rows.

Tests added:

  • getRangeWithLimitZeroReturnsEmpty — integration test verifying limit=0 returns empty
  • getRangeAllWithLimitZeroReturnsEmpty — same for eager fetch

All 326 unit tests pass.

…s batch

Previously, passing limit=0 to RangeOptions was interpreted as 'unlimited'
by the underlying FoundationDB call for the first batch, and then the
loop broke immediately because fetched (0) >= limit (0). This produced
an ambiguous single-batch result.

Now limit=0 is explicitly treated as 'no rows': the generator returns
immediately with zero results. Use limit=null for unlimited results.

Closes #51
@s2x
s2x merged commit 1e9f8ac into master Jul 3, 2026
5 of 6 checks passed
@s2x
s2x deleted the fix/issue-51-range-limit-zero branch July 3, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] RangeResult treats an explicit limit of 0 as a single batch

1 participant