diff options
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/oracle.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/arel/visitors/oracle.rb b/lib/arel/visitors/oracle.rb index 875b0e5b6a..4c79c4b038 100644 --- a/lib/arel/visitors/oracle.rb +++ b/lib/arel/visitors/oracle.rb @@ -26,11 +26,22 @@ module Arel FROM (" collector = super(o, collector) - collector << ") raw_sql_ + + if offset.expr.is_a? Nodes::BindParam + offset_bind = nil + collector << ') raw_sql_ WHERE rownum <= (' + collector.add_bind(offset.expr) { |i| offset_bind = ":a#{i}" } + collector << ' + ' + collector.add_bind(limit) { |i| ":a#{i}" } + collector << ") ) WHERE raw_rnum_ > #{offset_bind}" + return collector + else + collector << ") raw_sql_ WHERE rownum <= #{offset.expr.to_i + limit} ) WHERE " - return visit(offset, collector) + return visit(offset, collector) + end end if o.limit |