Skip to content

Commit

Permalink
switch from deprecated query method to Arel query
Browse files Browse the repository at this point in the history
  • Loading branch information
lostapathy committed Jan 16, 2012
1 parent 82529a1 commit 98e9a5d
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/serialization_helper.rb
Expand Up @@ -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
Expand Down

0 comments on commit 98e9a5d

Please sign in to comment.