diff options
Diffstat (limited to 'lib/arel/visitors/to_sql.rb')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 264521f4c6..ae1b7930af 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -103,9 +103,7 @@ module Arel collector << "UPDATE " collector = visit o.relation, collector - values = false unless o.values.empty? - values = true collector << " SET " collector = inject_join o.values, collector, ", " end @@ -300,8 +298,9 @@ module Arel raise NotImplementedError, 'DISTINCT ON not implemented for this db' end - def visit_Arel_Nodes_With o - "WITH #{o.children.map { |x| visit x }.join(', ')}" + def visit_Arel_Nodes_With o, collector + collector << "WITH " + inject_join o.children, collector, ', ' end def visit_Arel_Nodes_WithRecursive o, collector @@ -337,12 +336,20 @@ 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 << ' ' 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 @@ -719,7 +726,7 @@ module Arel quote(o, column_for(a)) end - def unsupported o + def unsupported o, collector raise "unsupported: #{o.class.name}" end |