diff options
author | Derek Prior <derekprior@gmail.com> | 2013-10-15 13:04:58 -0400 |
---|---|---|
committer | Derek Prior <derekprior@gmail.com> | 2013-10-15 13:11:43 -0400 |
commit | 23dfc39ed9db4591bb7b22ea6abaf7b965d1bed5 (patch) | |
tree | 8936f2cee3eee75e4c97e073f8b2230c81f0c933 | |
parent | dd37ff81d13136a5e8a78f79d8b1cd11e2427e01 (diff) | |
download | rails-23dfc39ed9db4591bb7b22ea6abaf7b965d1bed5.tar.gz rails-23dfc39ed9db4591bb7b22ea6abaf7b965d1bed5.tar.bz2 rails-23dfc39ed9db4591bb7b22ea6abaf7b965d1bed5.zip |
Pluck on NullRelation accepts a list of columns
`pluck` was updated to accept a list of columns, but the `NullRelation`
was never updated to match that signature. As a result, calling `pluck`
on a `NullRelation` results in an `ArgumentError`.
-rw-r--r-- | activerecord/CHANGELOG.md | 7 | ||||
-rw-r--r-- | activerecord/lib/active_record/null_relation.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 2 |
3 files changed, 9 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index 0b7fbe5a48..f3f0aa705c 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,10 @@ +* `NullRelation#pluck` takes a list of columns + + The method signature in `NullRelation` was updated to mimic that in + `Calculations`. + + *Derek Prior* + * `scope_chain` should not be mutated for other reflections. Currently `scope_chain` uses same array for building different diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb index 1f3d377e53..080b20134d 100644 --- a/activerecord/lib/active_record/null_relation.rb +++ b/activerecord/lib/active_record/null_relation.rb @@ -6,7 +6,7 @@ module ActiveRecord @records = [] end - def pluck(_column_name) + def pluck(*column_names) [] end diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index ec43ded690..860bd424b7 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -274,7 +274,7 @@ class RelationTest < ActiveRecord::TestCase def test_none_chained_to_methods_firing_queries_straight_to_db assert_no_queries do - assert_equal [], Developer.none.pluck(:id) # => uses select_all + assert_equal [], Developer.none.pluck(:id, :name) assert_equal 0, Developer.none.delete_all assert_equal 0, Developer.none.update_all(:name => 'David') assert_equal 0, Developer.none.delete(1) |