No need to call to_sym here
The hash is now string-keyed, and [_]reflect_on_association calls `to_s` on the argument anyway.
This commit is contained in:
parent
90f9968912
commit
1a2e3a0431
|
@ -20,7 +20,7 @@ module ActiveRecord
|
|||
def reset_counters(id, *counters)
|
||||
object = find(id)
|
||||
counters.each do |counter_association|
|
||||
has_many_association = _reflect_on_association(counter_association.to_sym)
|
||||
has_many_association = _reflect_on_association(counter_association)
|
||||
unless has_many_association
|
||||
has_many = reflect_on_all_associations(:has_many)
|
||||
has_many_association = has_many.find { |association| association.counter_cache_column && association.counter_cache_column.to_sym == counter_association.to_sym }
|
||||
|
|
|
@ -19,15 +19,15 @@ module ActiveRecord
|
|||
#
|
||||
# Person.group(:city).count
|
||||
# # => { 'Rome' => 5, 'Paris' => 3 }
|
||||
#
|
||||
# If +count+ is used with +group+ for multiple columns, it returns a Hash whose
|
||||
# keys are an array containing the individual values of each column and the value
|
||||
#
|
||||
# If +count+ is used with +group+ for multiple columns, it returns a Hash whose
|
||||
# keys are an array containing the individual values of each column and the value
|
||||
# of each key would be the +count+.
|
||||
#
|
||||
#
|
||||
# Article.group(:status, :category).count
|
||||
# # => {["draft", "business"]=>10, ["draft", "technology"]=>4,
|
||||
# # => {["draft", "business"]=>10, ["draft", "technology"]=>4,
|
||||
# ["published", "business"]=>0, ["published", "technology"]=>2}
|
||||
#
|
||||
#
|
||||
# If +count+ is used with +select+, it will count the selected columns:
|
||||
#
|
||||
# Person.select(:age).count
|
||||
|
@ -274,7 +274,7 @@ module ActiveRecord
|
|||
group_attrs = group_values
|
||||
|
||||
if group_attrs.first.respond_to?(:to_sym)
|
||||
association = @klass._reflect_on_association(group_attrs.first.to_sym)
|
||||
association = @klass._reflect_on_association(group_attrs.first)
|
||||
associated = group_attrs.size == 1 && association && association.belongs_to? # only count belongs_to associations
|
||||
group_fields = Array(associated ? association.foreign_key : group_attrs)
|
||||
else
|
||||
|
|
|
@ -26,7 +26,7 @@ module ActiveRecord
|
|||
queries << '1=0'
|
||||
else
|
||||
table = Arel::Table.new(column, default_table.engine)
|
||||
association = klass._reflect_on_association(column.to_sym)
|
||||
association = klass._reflect_on_association(column)
|
||||
|
||||
value.each do |k, v|
|
||||
queries.concat expand(association && association.klass, table, k, v)
|
||||
|
@ -55,7 +55,7 @@ module ActiveRecord
|
|||
#
|
||||
# For polymorphic relationships, find the foreign key and type:
|
||||
# PriceEstimate.where(estimate_of: treasure)
|
||||
if klass && reflection = klass._reflect_on_association(column.to_sym)
|
||||
if klass && reflection = klass._reflect_on_association(column)
|
||||
if reflection.polymorphic? && base_class = polymorphic_base_class_from_value(value)
|
||||
queries << build(table[reflection.foreign_type], base_class)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue