Skip to content

Commit

Permalink
Merge pull request #1277 from thiago-gitlab/rails-pick-description
Browse files Browse the repository at this point in the history
Warn about subqueries when replacing pluck with pick
  • Loading branch information
koic authored May 13, 2024
2 parents b2c2450 + acc1f4f commit 582af1e
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 582af1e

Please sign in to comment.