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-13 15:50:11 +0100 |
commit | d3006f3503cd62510f669fcac84f8dc47c3b333c (patch) | |
tree | b369a5fcc68f0584d75e2ad571273f25c867cd0f /activerecord/lib/active_record/relation/calculations.rb | |
parent | 267fb61277ac960ad443d239febcb3136a007d24 (diff) | |
download | rails-d3006f3503cd62510f669fcac84f8dc47c3b333c.tar.gz rails-d3006f3503cd62510f669fcac84f8dc47c3b333c.tar.bz2 rails-d3006f3503cd62510f669fcac84f8dc47c3b333c.zip |
backport #8176, `#pluck` can be used on a relation with `select` clause.
Conflicts:
activerecord/CHANGELOG.md
activerecord/lib/active_record/relation/calculations.rb
activerecord/test/cases/calculations_test.rb
Diffstat (limited to 'activerecord/lib/active_record/relation/calculations.rb')
-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 802059db21..8b605dd4f1 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -178,7 +178,9 @@ module ActiveRecord # def pluck(column_name) column_name = column_name.to_s - klass.connection.select_all(select(column_name).arel).map! do |attributes| + relation = clone + relation.select_values = [column_name] + klass.connection.select_all(relation.arel).map! do |attributes| klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes)) end end |