Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

switch from deprecated query method to Arel query

  • Loading branch information...
commit 98e9a5dca43e3fedd3268c76a73af40d1bdf1dfd 1 parent 82529a1
@lostapathy lostapathy authored
Showing with 2 additions and 4 deletions.
  1. +2 −4 lib/serialization_helper.rb
View
6 lib/serialization_helper.rb
@@ -181,10 +181,8 @@ def self.each_table_page(table, records_per_page=1000)
quoted_table_name = SerializationHelper::Utils.quote_table(table)
(0..pages).to_a.each do |page|
- sql = ActiveRecord::Base.connection.add_limit_offset!("SELECT * FROM #{quoted_table_name} ORDER BY #{id}",
- :limit => records_per_page, :offset => records_per_page * page
- )
- records = ActiveRecord::Base.connection.select_all(sql)
+ query = Arel::Table.new(table).order(id).skip(records_per_page*page).take(records_per_page).project(Arel.sql('*'))
+ records = ActiveRecord::Base.connection.select_all(query)
records = SerializationHelper::Utils.convert_booleans(records, boolean_columns)
yield records
end
Please sign in to comment.
Something went wrong with that request. Please try again.