Add `ResultSet#column_names`. Fixes #11
This commit is contained in:
parent
1a4622ee59
commit
b5112d9a48
|
@ -56,4 +56,12 @@ describe DB::ResultSet do
|
|||
|
||||
cols.should eq(["c0", "c1"])
|
||||
end
|
||||
|
||||
it "gets all column names" do
|
||||
with_dummy do |db|
|
||||
db.query "1,2" do |rs|
|
||||
rs.column_names.should eq(%w(c0 c1))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -61,6 +61,11 @@ module DB
|
|||
# Returns the name of the column in `index` 0-based position.
|
||||
abstract def column_name(index : Int32) : String
|
||||
|
||||
# Returns the name of the columns.
|
||||
def column_names
|
||||
Array(String).new(column_count) { |i| column_name(i) }
|
||||
end
|
||||
|
||||
# Reads the next column value
|
||||
abstract def read
|
||||
|
||||
|
|
Loading…
Reference in New Issue