diff options
author | José Valim <jose.valim@plataformatec.com.br> | 2012-02-08 06:41:54 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-12-03 23:17:16 -0200 |
commit | a878126028471626a9b30ebe60b7306374fb74ca (patch) | |
tree | d801fbe07b897cc8ce83a3dab8ef7b0031950c6f /activerecord/test/cases | |
parent | 1a5caf180e22970a5ca927e9315a1af9f6bf6495 (diff) | |
download | rails-a878126028471626a9b30ebe60b7306374fb74ca.tar.gz rails-a878126028471626a9b30ebe60b7306374fb74ca.tar.bz2 rails-a878126028471626a9b30ebe60b7306374fb74ca.zip |
Merge pull request #4942 from bogdan/pluck_joins
AR::Relation#pluck: improve to work with joins
Conflicts:
activerecord/lib/active_record/relation/calculations.rb
activerecord/test/cases/calculations_test.rb
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/calculations_test.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb index 63383bded9..ab573d8cc8 100644 --- a/activerecord/test/cases/calculations_test.rb +++ b/activerecord/test/cases/calculations_test.rb @@ -493,4 +493,14 @@ class CalculationsTest < ActiveRecord::TestCase assert_equal [1,2,3,4], taks_relation.pluck(:id) assert_equal [false, true, true, true], taks_relation.pluck(:approved) end + + def test_pluck_auto_table_name_prefix + c = Company.create!(:name => "test", :contracts => [Contract.new]) + assert_equal [c.id], Company.joins(:contracts).pluck(:id) + end + + def test_pluck_not_auto_table_name_prefix_if_column_joined + c = Company.create!(:name => "test", :contracts => [Contract.new(:developer_id => 7)]) + assert_equal [7], Company.joins(:contracts).pluck(:developer_id).map(&:to_i) + end end |