mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
monkey patching with enumerable so we can call each
This commit is contained in:
parent
fe2ee4fafd
commit
eb83eb6c98
1 changed files with 4 additions and 10 deletions
|
@ -17,17 +17,12 @@ class Mysql
|
|||
class Time
|
||||
###
|
||||
# This monkey patch is for test_additional_columns_from_join_table
|
||||
|
||||
def to_date
|
||||
Date.new(year, month, day)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Mysql
|
||||
class Stmt
|
||||
include Enumerable
|
||||
end
|
||||
class Stmt; include Enumerable end
|
||||
class Result; include Enumerable end
|
||||
end
|
||||
|
||||
module ActiveRecord
|
||||
|
@ -357,10 +352,9 @@ module ActiveRecord
|
|||
log(sql, name) do
|
||||
result = @connection.query(sql)
|
||||
cols = result.fetch_fields.map { |field| field.name }
|
||||
values = []
|
||||
result.each { |row| values << row }
|
||||
rows = result.to_a
|
||||
result.free
|
||||
ActiveRecord::Result.new(cols, values)
|
||||
ActiveRecord::Result.new(cols, rows)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue