mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
add length to ActiveRecord::Result
This commit is contained in:
parent
3c3a344aec
commit
f0c2c6469f
2 changed files with 8 additions and 0 deletions
|
@ -42,6 +42,10 @@ module ActiveRecord
|
|||
@column_types = column_types
|
||||
end
|
||||
|
||||
def length
|
||||
@rows.length
|
||||
end
|
||||
|
||||
def each
|
||||
if block_given?
|
||||
hash_rows.each { |row| yield row }
|
||||
|
|
|
@ -10,6 +10,10 @@ module ActiveRecord
|
|||
])
|
||||
end
|
||||
|
||||
test "length" do
|
||||
assert_equal 3, result.length
|
||||
end
|
||||
|
||||
test "to_hash returns row_hashes" do
|
||||
assert_equal [
|
||||
{'col_1' => 'row 1 col 1', 'col_2' => 'row 1 col 2'},
|
||||
|
|
Loading…
Reference in a new issue