1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove deprecated support to passing arguments to #select when a block is provided.

This commit is contained in:
Rafael Mendonça França 2016-12-29 15:39:50 -05:00
parent fc3e679647
commit 4fc3366d9d
No known key found for this signature in database
GPG key ID: FC23B6D0F1EEE948
3 changed files with 5 additions and 10 deletions

View file

@ -1,3 +1,7 @@
* Remove deprecated support to passing arguments to `#select` when a block is provided.
*Rafael Mendonça França*
* Remove deprecated support to query using commas on LIMIT.
*Rafael Mendonça França*

View file

@ -243,9 +243,7 @@ module ActiveRecord
def select(*fields)
if block_given?
if fields.any?
ActiveSupport::Deprecation.warn(<<-WARNING.squish)
When select is called with a block, it ignores other arguments. This behavior is now deprecated and will result in an ArgumentError in Rails 5.1. You can safely remove the arguments to resolve the deprecation warning because they do not have any effect on the output of the call to the select method with a block.
WARNING
raise ArgumentError, "`select' with block doesn't take arguments."
end
return super()

View file

@ -788,13 +788,6 @@ class HasManyAssociationsTest < ActiveRecord::TestCase
assert_equal [1], posts(:welcome).comments.select { |c| c.id == 1 }.map(&:id)
end
def test_select_with_block_and_specific_attributes
assert_deprecated do
comments = posts(:welcome).comments.select(:id, :body) { |c| c.id == 1 }
assert_equal [1], comments.map(&:id)
end
end
def test_select_without_foreign_key
assert_equal companies(:first_firm).accounts.first.credit_limit, companies(:first_firm).accounts.select(:credit_limit).first.credit_limit
end