Skip to content

Commit

Permalink
Remove deprecated support to passing arguments to #select when a bl…
Browse files Browse the repository at this point in the history
…ock is provided.
  • Loading branch information
rafaelfranca committed Dec 29, 2016
1 parent fc3e679 commit 4fc3366
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
4 changes: 4 additions & 0 deletions activerecord/CHANGELOG.md
@@ -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*
Expand Down
4 changes: 1 addition & 3 deletions activerecord/lib/active_record/relation/query_methods.rb
Expand Up @@ -243,9 +243,7 @@ def references!(*table_names) # :nodoc:
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()
Expand Down
Expand Up @@ -788,13 +788,6 @@ def test_select_with_block
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
Expand Down

0 comments on commit 4fc3366

Please sign in to comment.