Skip to content

Commit acc1f4f

Browse files
committed
Warn about subqueries when replacing pluck with pick
1 parent b2c2450 commit acc1f4f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Diff for: lib/rubocop/cop/rails/pick.rb

+4
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ module Rails
99
# `pick` avoids. When called on an Active Record relation, `pick` adds a
1010
# limit to the query so that only one value is fetched from the database.
1111
#
12+
# Note that when `pick` is added to a relation with an existing limit, it
13+
# causes a subquery to be added. In most cases this is undesirable, and
14+
# care should be taken while resolving this violation.
15+
#
1216
# @safety
1317
# This cop is unsafe because `pluck` is defined on both `ActiveRecord::Relation` and `Enumerable`,
1418
# whereas `pick` is only defined on `ActiveRecord::Relation` in Rails 6.0. This was addressed

0 commit comments

Comments
 (0)