Class: RuboCop::Cop::Spbtv::Postgres::FindEach
- Inherits:
-
RuboCop::Cop
- Object
- RuboCop::Cop
- RuboCop::Cop::Spbtv::Postgres::FindEach
- Defined in:
- lib/rubocop/cop/spbtv/postgres/find_each.rb
Overview
Do not use find_each with Postgresql.
ActiveRecord’s find_each and find_in_batches ignore non-integer primary keys, thus limiting output to 1000 records. Workaround: use github.com/afair/postgresql_cursor gem with its each_instance method.
Constant Summary collapse
- MSG =
'Do not use find_each or find_in_batches, as the keys are non-integer.'.freeze
Instance Method Summary collapse
Instance Method Details
#on_send(node) ⇒ Object
22 23 24 25 26 27 |
# File 'lib/rubocop/cop/spbtv/postgres/find_each.rb', line 22 def on_send(node) _, method, * = *node if method == :find_each || method == :find_in_batches add_offense(node, :selector, MSG) end end |