aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/to_sql.rb
diff options
context:
space:
mode:
authorAlexander Staubo <alex@bengler.no>2013-02-19 22:27:17 +0100
committerAlexander Staubo <alex@bengler.no>2014-06-20 17:08:05 -0400
commit69e9be95ac233eb7b446920bb49399277ea594ce (patch)
tree041be9088a60edddebb6dba93ce9dfe16bcd0345 /lib/arel/visitors/to_sql.rb
parentf50de54a6f0c59ab75526cfdb7896830130ffdf7 (diff)
downloadrails-69e9be95ac233eb7b446920bb49399277ea594ce.tar.gz
rails-69e9be95ac233eb7b446920bb49399277ea594ce.tar.bz2
rails-69e9be95ac233eb7b446920bb49399277ea594ce.zip
Windowing support for PARTITION BY clause.
Diffstat (limited to 'lib/arel/visitors/to_sql.rb')
-rw-r--r--lib/arel/visitors/to_sql.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index 7f74ebb402..8a5e1dbf25 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -336,6 +336,12 @@ module Arel
def visit_Arel_Nodes_Window o, collector
collector << "("
+
+ if o.partitions.any?
+ collector << "PARTITION BY "
+ collector = inject_join o.partitions, collector, ", "
+ end
+
if o.orders.any?
collector << "ORDER BY "
collector = inject_join o.orders, collector, ", "