diff options
author | Alexander Staubo <alex@bengler.no> | 2013-02-19 22:27:17 +0100 |
---|---|---|
committer | Alexander Staubo <alex@bengler.no> | 2014-06-20 17:08:05 -0400 |
commit | 69e9be95ac233eb7b446920bb49399277ea594ce (patch) | |
tree | 041be9088a60edddebb6dba93ce9dfe16bcd0345 /lib/arel/nodes | |
parent | f50de54a6f0c59ab75526cfdb7896830130ffdf7 (diff) | |
download | rails-69e9be95ac233eb7b446920bb49399277ea594ce.tar.gz rails-69e9be95ac233eb7b446920bb49399277ea594ce.tar.bz2 rails-69e9be95ac233eb7b446920bb49399277ea594ce.zip |
Windowing support for PARTITION BY clause.
Diffstat (limited to 'lib/arel/nodes')
-rw-r--r-- | lib/arel/nodes/window.rb | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/arel/nodes/window.rb b/lib/arel/nodes/window.rb index 60259e8c05..6578a414d2 100644 --- a/lib/arel/nodes/window.rb +++ b/lib/arel/nodes/window.rb @@ -1,10 +1,12 @@ module Arel module Nodes class Window < Arel::Nodes::Node - attr_accessor :orders, :framing + attr_accessor :orders, :framing, :partitions def initialize @orders = [] + @partitions = [] + @framing = nil end def order *expr @@ -15,6 +17,14 @@ module Arel self end + def partition *expr + # FIXME: We SHOULD NOT be converting these to SqlLiteral automatically + @partitions.concat expr.map { |x| + String === x || Symbol === x ? Nodes::SqlLiteral.new(x.to_s) : x + } + self + end + def frame(expr) @framing = expr end @@ -39,7 +49,8 @@ module Arel def eql? other self.class == other.class && self.orders == other.orders && - self.framing == other.framing + self.framing == other.framing && + self.partitions == other.partitions end alias :== :eql? end |