aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/oracle.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/arel/visitors/oracle.rb')
-rw-r--r--lib/arel/visitors/oracle.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/arel/visitors/oracle.rb b/lib/arel/visitors/oracle.rb
new file mode 100644
index 0000000000..840a7a9ace
--- /dev/null
+++ b/lib/arel/visitors/oracle.rb
@@ -0,0 +1,15 @@
+module Arel
+ module Visitors
+ class Oracle < Arel::Visitors::ToSql
+ def visit_Arel_Nodes_SelectStatement o
+ if o.limit
+ o.cores.last.wheres.push Nodes::LessThanOrEqual.new(
+ Nodes::SqlLiteral.new('ROWNUM'), o.limit
+ )
+ o.limit = nil
+ end
+ super
+ end
+ end
+ end
+end