diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-06-11 14:32:00 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-06-11 15:12:36 -0600 |
commit | fef044cd2bd167201462861385ebf38bbf3158d7 (patch) | |
tree | d173e9b6834bd0bc2c795e6ce5f5131f82b4f6bf /activerecord/lib | |
parent | 1b14bff81a9ab6654badf52b552f90c8fc3ab0e3 (diff) | |
download | rails-fef044cd2bd167201462861385ebf38bbf3158d7.tar.gz rails-fef044cd2bd167201462861385ebf38bbf3158d7.tar.bz2 rails-fef044cd2bd167201462861385ebf38bbf3158d7.zip |
Pluck should work with columns of the same name from different tables
The column name given by the adapter doesn't include the table
namespace, so going through the hashed version of the result set causes
overridden keys.
Fixes #15649
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 38970a66ae..028e4d80ab 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -176,9 +176,7 @@ module ActiveRecord } end - result = result.map do |attributes| - values = attributes.values - + result = result.rows.map do |values| columns.zip(values).map { |column, value| column.type_cast_from_database value } end columns.one? ? result.map!(&:first) : result |