Permalink
Browse files

Use the connection adapter to handle limit and offset (was broken for…

… Oracle)
  • Loading branch information...
1 parent 8029d32 commit 4b740bc4ccc4092549fb9c1eec2fbd2ed70b8042 @tslocke tslocke committed with adamwiggins Jul 24, 2008
Showing with 4 additions and 2 deletions.
  1. +4 −2 lib/yaml_db.rb
View
@@ -113,8 +113,10 @@ def self.each_table_page(table, records_per_page=1000)
boolean_columns = YamlDb::Utils.boolean_columns(table)
(0..pages).to_a.each do |page|
- sql_limit = "LIMIT #{records_per_page} OFFSET #{records_per_page*page}"
- records = ActiveRecord::Base.connection.select_all("SELECT * FROM #{table} ORDER BY #{id} #{sql_limit}")
+ sql = ActiveRecord::Base.connection.add_limit_offset!("SELECT * FROM #{table} ORDER BY #{id}",
+ :limit => records_per_page, :offset => records_per_page * page
+ )
+ records = ActiveRecord::Base.connection.select_all(sql)
records = YamlDb::Utils.convert_booleans(records, boolean_columns)
yield records
end

0 comments on commit 4b740bc

Please sign in to comment.