diff options
author | Rafael França <rafaelmfranca@gmail.com> | 2016-10-07 15:28:48 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-07 15:28:48 -0400 |
commit | 3eddc2fd444c8a0a5f6c96614874d1437b5b55ab (patch) | |
tree | d20255ace6a58aa83104f7fe387889fdbc790102 /lib/arel/visitors | |
parent | 44d2ef9623847dea5cbf6208ae7b5168b374c720 (diff) | |
parent | 9d6e569ddfed10b437494ecb6e995048737beb44 (diff) | |
download | rails-3eddc2fd444c8a0a5f6c96614874d1437b5b55ab.tar.gz rails-3eddc2fd444c8a0a5f6c96614874d1437b5b55ab.tar.bz2 rails-3eddc2fd444c8a0a5f6c96614874d1437b5b55ab.zip |
Merge pull request #450 from roooodcastro/issue-438
Use Arel::Nodes::BindParam in Oracle visitor for queries using both LIMIT and OFFSET
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 |