diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-09-10 21:41:37 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-09-11 07:58:44 +0900 |
commit | 0d513699710216ee57dfd9ca678af10630fc9130 (patch) | |
tree | 3006f3683a8a6f39d49bce3219953fa6e93ae5b9 /activerecord/lib/active_record/relation | |
parent | cf5f55cd30aef0f90300c7c8f333060fe258cd8a (diff) | |
download | rails-0d513699710216ee57dfd9ca678af10630fc9130.tar.gz rails-0d513699710216ee57dfd9ca678af10630fc9130.tar.bz2 rails-0d513699710216ee57dfd9ca678af10630fc9130.zip |
Rename variable name that returning `type_for` to `type` from `column`
`column_for` was changed to `type_for` to return `type` object at
36bd52b4. But variable name is still `column`. It is very confusing.
Rename variable name `column` to `type` for readability.
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index a796e35261..9dd2410e51 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -252,11 +252,11 @@ module ActiveRecord result = @klass.connection.select_all(query_builder, nil, bound_attributes) row = result.first value = row && row.values.first - column = result.column_types.fetch(column_alias) do + type = result.column_types.fetch(column_alias) do type_for(column_name) end - type_cast_calculated_value(value, column, operation) + type_cast_calculated_value(value, type, operation) end def execute_grouped_calculation(operation, column_name, distinct) #:nodoc: @@ -310,18 +310,16 @@ module ActiveRecord Hash[calculated_data.map do |row| key = group_columns.map { |aliaz, col_name| - column = type_for(col_name) do - calculated_data.column_types.fetch(aliaz) do - Type.default_value - end + type = type_for(col_name) do + calculated_data.column_types.fetch(aliaz, Type.default_value) end - type_cast_calculated_value(row[aliaz], column) + type_cast_calculated_value(row[aliaz], type) } key = key.first if key.size == 1 key = key_records[key] if associated - column_type = calculated_data.column_types.fetch(aggregate_alias) { type_for(column_name) } - [key, type_cast_calculated_value(row[aggregate_alias], column_type, operation)] + type = calculated_data.column_types.fetch(aggregate_alias) { type_for(column_name) } + [key, type_cast_calculated_value(row[aggregate_alias], type, operation)] end] end @@ -356,7 +354,7 @@ module ActiveRecord when "count" then value.to_i when "sum" then type.deserialize(value || 0) when "average" then value.respond_to?(:to_d) ? value.to_d : value - else type.deserialize(value) + else type.deserialize(value) end end |