Method: Sequel::Postgres::Dataset#where_current_of
- Defined in:
- lib/sequel/adapters/postgres.rb
#where_current_of(cursor_name = 'sequel_cursor') ⇒ Object
Replace the WHERE clause with one that uses CURRENT OF with the given cursor name (or the default cursor name). This allows you to update a large dataset by updating individual rows while processing the dataset via a cursor:
DB[:huge_table].use_cursor(rows_per_fetch: 1).each do |row|
DB[:huge_table].where_current_of.update(column: ruby_method(row))
end
698 699 700 |
# File 'lib/sequel/adapters/postgres.rb', line 698 def where_current_of(cursor_name='sequel_cursor') clone(:where=>Sequel.lit(['CURRENT OF '], Sequel.identifier(cursor_name))) end |