fix: RangeResult limit=0 returns empty result instead of ambiguous batch (#51) - #59
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #51
Problem:
RangeResulttreatedlimit: 0as "unlimited" for the first batch (because FoundationDB C API interprets 0 as unlimited), then broke immediately becausefetched (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: nullremains the way to request all matching rows.Tests added:
getRangeWithLimitZeroReturnsEmpty— integration test verifying limit=0 returns emptygetRangeAllWithLimitZeroReturnsEmpty— same for eager fetchAll 326 unit tests pass.