Allow calling each, each_hash without block#656
Open
kch wants to merge 6 commits intosparklemotion:mainfrom
Open
Allow calling each, each_hash without block#656kch wants to merge 6 commits intosparklemotion:mainfrom
kch wants to merge 6 commits intosparklemotion:mainfrom
Conversation
flavorjones
reviewed
Nov 29, 2025
Member
flavorjones
left a comment
There was a problem hiding this comment.
Thanks for opening this PR! This is a nice quality-of-life improvement. I have just a couple of comments about the test coverage (which I have been trying to improve with every PR).
Comment on lines
120
to
136
| def test_each_enum | ||
| called = 0 | ||
| @result.reset(1, 2) | ||
| @result.each.to_a.each { |row| called += 1 } | ||
| assert_equal 2, called | ||
| end |
Member
There was a problem hiding this comment.
I would like this test to also assert that the .each returns an Enumerator object. I'd also like a similar test for .each_hash, something like:
def test_each_enum
@result.reset(1, 2)
enum = @result.each
assert_instance_of Enumerator, enum
assert_equal 2, enum.to_a.length
end
def test_each_hash_enum
@result.reset(1, 2)
enum = @result.each_hash
assert_instance_of Enumerator, enum
assert_equal 2, enum.to_a.length
end
Author
There was a problem hiding this comment.
yeah those are fine, just copied over. I also noticed we should return self when no block, so also added tests for that.
flavorjones
reviewed
Nov 29, 2025
lib/sqlite3/resultset.rb
Outdated
| @@ -46,6 +46,7 @@ def next | |||
| # Required by the Enumerable mixin. Provides an internal iterator over the | |||
| # rows of the result set. | |||
Member
There was a problem hiding this comment.
Please also update the docstring!
flavorjones
reviewed
Nov 29, 2025
lib/sqlite3/resultset.rb
Outdated
| @@ -54,6 +55,7 @@ def each | |||
| # Provides an internal iterator over the rows of the result set where | |||
| # each row is yielded as a hash. | |||
Member
There was a problem hiding this comment.
Please also update the docstring!
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.
Returns an enumerator. Matching similar methods in ruby stdlib.