FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Allow calling each, each_hash without block by kch · Pull Request #656 · sparklemotion/sqlite3-ruby · GitHub

Allow calling each, each_hash without block - #656

Open
kch wants to merge 6 commits into
sparklemotion:mainfrom
kch:each_hash_enum
Open

Allow calling each, each_hash without block#656
kch wants to merge 6 commits into
sparklemotion:mainfrom
kch:each_hash_enum

Conversation

kch commented Nov 19, 2025
edited
Loading

Copy link
Copy Markdown

Returns an enumerator. Matching similar methods in ruby stdlib.

kch changed the title Allow calling each_hash without block Allow calling each, each_hash without block Nov 19, 2025

flavorjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 thread test/test_result_set.rb Outdated
Comment on lines +120 to +125
def test_each_enum
called = 0
@result.reset(1, 2)
@result.each.to_a.each { |row| called += 1 }
assert_equal 2, called
end

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

yeah those are fine, just copied over. I also noticed we should return self when no block, so also added tests for that.

Comment thread 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please also update the docstring!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

changed. lmk if good.

Comment thread 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.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please also update the docstring!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

changed. lmk if good.

Copy link
Copy Markdown
Member

Sorry for the delay here, I've got a large open-source backlog at the moment and plan to get back to this shortly.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL