diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-13 06:27:42 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-11-13 06:27:42 -0800 |
commit | 3a335720db249700c3d7d51ee450a6bf22aff5fd (patch) | |
tree | c4f678d033d51ea912b7caa1506cf96031466ca5 /activerecord/lib/active_record | |
parent | 12990c4e61d06a4b86f918b51a6702fe342d2736 (diff) | |
parent | 663d9ef67003d3bec44295d29f3c254951202926 (diff) | |
download | rails-3a335720db249700c3d7d51ee450a6bf22aff5fd.tar.gz rails-3a335720db249700c3d7d51ee450a6bf22aff5fd.tar.bz2 rails-3a335720db249700c3d7d51ee450a6bf22aff5fd.zip |
Merge pull request #8176 from senny/7551_pluck_with_select
`#pluck` can be used on a relation with `select` clause (#7551)
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index a7d2f4bd24..df27318678 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -165,7 +165,9 @@ module ActiveRecord if has_include?(column_names.first) construct_relation_for_association_calculations.pluck(*column_names) else - result = klass.connection.select_all(select(column_names).arel, nil, bind_values) + relation = spawn + relation.select_values = column_names + result = klass.connection.select_all(relation.arel, nil, bind_values) columns = result.columns.map do |key| klass.column_types.fetch(key) { result.column_types.fetch(key) { |