aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/arel/nodes/window.rb12
-rw-r--r--lib/arel/visitors/to_sql.rb2
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/arel/nodes/window.rb b/lib/arel/nodes/window.rb
index 6578a414d2..fee8eeff7a 100644
--- a/lib/arel/nodes/window.rb
+++ b/lib/arel/nodes/window.rb
@@ -30,11 +30,19 @@ module Arel
end
def rows(expr = nil)
- frame(Rows.new(expr))
+ if @framing
+ Rows.new(expr)
+ else
+ frame(Rows.new(expr))
+ end
end
def range(expr = nil)
- frame(Range.new(expr))
+ if @framing
+ Range.new(expr)
+ else
+ frame(Range.new(expr))
+ end
end
def initialize_copy other
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index 8a5e1dbf25..8c63070084 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -343,11 +343,13 @@ module Arel
end
if o.orders.any?
+ collector << ' ' if o.partitions.any?
collector << "ORDER BY "
collector = inject_join o.orders, collector, ", "
end
if o.framing
+ collector << ' ' if o.partitions.any? or o.orders.any?
collector = visit o.framing, collector
end