aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-03-18 18:25:45 -0300
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2013-03-18 18:28:07 -0300
commit167b645a2a0e983cb681d94adbe17480c824e701 (patch)
treef9a76ba37aed306e7fcaf2850753f56505d29553 /activerecord
parent91942219210bc68d09deea0801e54b9f7c187bc9 (diff)
downloadrails-167b645a2a0e983cb681d94adbe17480c824e701.tar.gz
rails-167b645a2a0e983cb681d94adbe17480c824e701.tar.bz2
rails-167b645a2a0e983cb681d94adbe17480c824e701.zip
Bring back test and changelog entry from #pluck method and select clause
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG.md10
-rw-r--r--activerecord/test/cases/calculations_test.rb6
2 files changed, 16 insertions, 0 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index f9c55ba0f4..2d05bd857f 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -238,6 +238,16 @@
*Victor Costan*
+* `#pluck` can be used on a relation with `select` clause.
+ Fixes #7551.
+ Backport of #8176.
+
+ Example:
+
+ Topic.select([:approved, :id]).order(:id).pluck(:id)
+
+ *Yves Senn*
+
* Use `nil?` instead of `blank?` to check whether dynamic finder with a bang
should raise RecordNotFound.
Fixes #7238.
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index 67137d168b..a1dc1de38d 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -493,6 +493,12 @@ class CalculationsTest < ActiveRecord::TestCase
assert_equal [1,2,3,4], Topic.order(:id).pluck("topics.id")
end
+ def test_pluck_replaces_select_clause
+ taks_relation = Topic.select([:approved, :id]).order(:id)
+ 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)