Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

moving column types to an ivar on the result

  • Loading branch information...
commit 00b62ab73bef05126fdfb72291beee60898c4f8e 1 parent ab6ebcc
Aaron Patterson tenderlove authored
6 activerecord/lib/active_record/attribute_methods/read.rb
View
@@ -125,7 +125,11 @@ def instance_cast_method(attr_name)
# Returns the value of the attribute identified by <tt>attr_name</tt> after it has been typecast (for example,
# "2004-12-12" in a data column is cast to a date object, like Date.new(2004, 12, 12)).
def read_attribute(attr_name)
- self.class.type_cast_attribute(attr_name, @attributes, @attributes_cache)
+ if @columns_hash.key? attr_name
+ @columns_hash[attr_name].type_cast @attributes[attr_name]
+ else
+ self.class.type_cast_attribute(attr_name, @attributes, @attributes_cache)
+ end
end
private
13 activerecord/lib/active_record/result.rb
View
@@ -8,12 +8,13 @@ module ActiveRecord
class Result
include Enumerable
- attr_reader :columns, :rows
+ attr_reader :columns, :rows, :column_types
def initialize(columns, rows)
- @columns = columns
- @rows = rows
- @hash_rows = nil
+ @columns = columns
+ @rows = rows
+ @hash_rows = nil
+ @column_types = {}
end
def each
@@ -49,10 +50,6 @@ def initialize_copy(other)
@hash_rows = nil
end
- def column_types
- {}
- end
-
private
def hash_rows
@hash_rows ||= @rows.map { |row|
Please sign in to comment.
Something went wrong with that request. Please try again.