Browse files

Merge pull request #100 from babinho/master

Fixing oracle issue with limit and offset if query is ordered
  • Loading branch information...
2 parents eebf5d7 + d1c9c46 commit cbdc7e72ba48672f6c43627de1d081e61c6c10b0 @tenderlove tenderlove committed Feb 17, 2012
Showing with 2 additions and 4 deletions.
  1. +1 −2 lib/arel/visitors/oracle.rb
  2. +1 −2 test/visitors/test_oracle.rb
View
3 lib/arel/visitors/oracle.rb
@@ -25,9 +25,8 @@ def visit_Arel_Nodes_SelectStatement o
SELECT * FROM (
SELECT raw_sql_.*, rownum raw_rnum_
FROM (#{sql}) raw_sql_
- WHERE rownum <= #{offset.expr.to_i + limit}
)
- WHERE #{visit offset}
+ WHERE raw_rnum_ between #{offset.expr.to_i + 1 } and #{offset.expr.to_i + limit}
eosql
end
View
3 test/visitors/test_oracle.rb
@@ -102,9 +102,8 @@ module Visitors
SELECT * FROM (
SELECT raw_sql_.*, rownum raw_rnum_
FROM (SELECT) raw_sql_
- WHERE rownum <= 20
)
- WHERE raw_rnum_ > 10
+ WHERE raw_rnum_ between 11 and 20
}
end

0 comments on commit cbdc7e7

Please sign in to comment.