mirror of
https://gitea.invidious.io/iv-org/shard-crystal-db.git
synced 2024-08-15 00:53:32 +00:00
allow result_set#each
This commit is contained in:
parent
4dd0312934
commit
c16dc42e96
2 changed files with 17 additions and 0 deletions
|
@ -54,5 +54,16 @@ describe DummyDriver do
|
|||
result_set.read(UInt64).should eq(1)
|
||||
result_set.read(UInt64).should eq(2)
|
||||
end
|
||||
|
||||
it "should enumerate records using each" do
|
||||
nums = [] of UInt64
|
||||
result_set = get_dummy.prepare("3,4 1,2").exec
|
||||
result_set.each do
|
||||
nums << result_set.read(UInt64)
|
||||
nums << result_set.read(UInt64)
|
||||
end
|
||||
|
||||
nums.should eq([3, 4, 1, 2])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,6 +5,12 @@ module DB
|
|||
def initialize(@statement : Statement)
|
||||
end
|
||||
|
||||
def each
|
||||
while has_next
|
||||
yield
|
||||
end
|
||||
end
|
||||
|
||||
abstract def has_next : Bool
|
||||
|
||||
# def read(t : T.class) : T
|
||||
|
|
Loading…
Reference in a new issue