diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-10 07:06:50 -0700 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2013-05-10 07:06:50 -0700 |
commit | 3589181122f1a70abc1acd8c6bf41b46e2be2f5a (patch) | |
tree | e2c75c57db9bfce2524df641cba63aa268c8fb0c /activerecord/lib | |
parent | 84c69a165380d4ae92322d4503a5b9a7201f6369 (diff) | |
parent | de5b89ddc9f9f45760856a1eb55f53a11d067a74 (diff) | |
download | rails-3589181122f1a70abc1acd8c6bf41b46e2be2f5a.tar.gz rails-3589181122f1a70abc1acd8c6bf41b46e2be2f5a.tar.bz2 rails-3589181122f1a70abc1acd8c6bf41b46e2be2f5a.zip |
Merge pull request #10552 from arunagw/pluck-fixed-3-2-stable
Pluck fixed 3 2 stable
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 71d33fcd4e..d4765a6782 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -179,13 +179,13 @@ module ActiveRecord def pluck(column_name) if column_name.is_a?(Symbol) && column_names.include?(column_name.to_s) column_name = "#{connection.quote_table_name(table_name)}.#{connection.quote_column_name(column_name)}" - else - column_name = column_name.to_s end - column_name = column_name.to_s + result = klass.connection.exec_query(select(column_name).to_sql) + last_column = result.columns.last + klass.connection.select_all(select(column_name).arel).map! do |attributes| - klass.type_cast_attribute(attributes.keys.first, klass.initialize_attributes(attributes)) + klass.type_cast_attribute(last_column, klass.initialize_attributes(attributes)) end end |