Skip to content

Commit

Permalink
Warn about subqueries when replacing pluck with pick
Browse files Browse the repository at this point in the history
  • Loading branch information
thiago-gitlab committed May 13, 2024
1 parent b2c2450 commit acc1f4f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rubocop/cop/rails/pick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ module Rails
# `pick` avoids. When called on an Active Record relation, `pick` adds a
# limit to the query so that only one value is fetched from the database.
#
# Note that when `pick` is added to a relation with an existing limit, it
# causes a subquery to be added. In most cases this is undesirable, and
# care should be taken while resolving this violation.
#
# @safety
# This cop is unsafe because `pluck` is defined on both `ActiveRecord::Relation` and `Enumerable`,
# whereas `pick` is only defined on `ActiveRecord::Relation` in Rails 6.0. This was addressed
Expand Down

0 comments on commit acc1f4f

Please sign in to comment.