diff options
author | Yves Senn <yves.senn@gmail.com> | 2012-11-11 17:15:26 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@garaio.com> | 2012-11-12 16:27:44 +0100 |
commit | 663d9ef67003d3bec44295d29f3c254951202926 (patch) | |
tree | c23d60d4b240a8025020703b8e4523e6dd7fdea1 /activerecord/lib/active_record | |
parent | d5ac2801d9ba6eea0add944e13ba8f5c8754f117 (diff) | |
download | rails-663d9ef67003d3bec44295d29f3c254951202926.tar.gz rails-663d9ef67003d3bec44295d29f3c254951202926.tar.bz2 rails-663d9ef67003d3bec44295d29f3c254951202926.zip |
`#pluck` can be used on a relation with `select` clause.
Closes #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) { |