aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-04-22 22:50:10 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-04-22 22:50:10 +0900
commit70e255b9f20ffa5d49b90cfaa4c30f5a53cc66a2 (patch)
tree60200cdef78a5318d9331dd274147eb52b0dcf15
parentada56f859113a5ab055c49b79a514cdae281d56b (diff)
downloadrails-70e255b9f20ffa5d49b90cfaa4c30f5a53cc66a2.tar.gz
rails-70e255b9f20ffa5d49b90cfaa4c30f5a53cc66a2.tar.bz2
rails-70e255b9f20ffa5d49b90cfaa4c30f5a53cc66a2.zip
Don't table name qualify aggrigate column for virtual attribute
Related 0ee96d13de29680e148ccb8e5b68025f29fd091c.
-rw-r--r--activerecord/lib/active_record/relation/calculations.rb6
1 files changed, 2 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb
index 801e312658..0be9ba7d7b 100644
--- a/activerecord/lib/active_record/relation/calculations.rb
+++ b/activerecord/lib/active_record/relation/calculations.rb
@@ -260,10 +260,8 @@ module ActiveRecord
def aggregate_column(column_name)
return column_name if Arel::Expressions === column_name
- if @klass.has_attribute?(column_name) || @klass.attribute_alias?(column_name)
- @klass.arel_attribute(column_name)
- else
- Arel.sql(column_name == :all ? "*" : column_name.to_s)
+ arel_column(column_name.to_s) do |name|
+ Arel.sql(column_name == :all ? "*" : name)
end
end