Permalink
Browse files

Bring back test and changelog entry from #pluck method and select clause

  • Loading branch information...
1 parent 9194221 commit 167b645a2a0e983cb681d94adbe17480c824e701 @carlosantoniodasilva carlosantoniodasilva committed Mar 18, 2013
Showing with 16 additions and 0 deletions.
  1. +10 −0 activerecord/CHANGELOG.md
  2. +6 −0 activerecord/test/cases/calculations_test.rb
View
@@ -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.
@@ -493,6 +493,12 @@ def test_pluck_with_qualified_column_name
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)

0 comments on commit 167b645

Please sign in to comment.