From d532b7ee430c5d0c412ab9f1a5e0dd3ebc47f86b Mon Sep 17 00:00:00 2001 From: Paul Sadauskas Date: Thu, 20 Jan 2011 12:56:08 -0700 Subject: Add support for WITH and UNION PostgreSQL WITH RECURSIVE support Make WITH be a unary node --- lib/arel/nodes/binary.rb | 2 ++ lib/arel/nodes/select_statement.rb | 14 ++++++++------ lib/arel/nodes/with.rb | 17 +++++++++++++++++ 3 files changed, 27 insertions(+), 6 deletions(-) create mode 100644 lib/arel/nodes/with.rb (limited to 'lib/arel/nodes') diff --git a/lib/arel/nodes/binary.rb b/lib/arel/nodes/binary.rb index 0d02554199..e72228f11c 100644 --- a/lib/arel/nodes/binary.rb +++ b/lib/arel/nodes/binary.rb @@ -29,6 +29,8 @@ module Arel NotEqual NotIn Or + Union + UnionAll }.each do |name| const_set name, Class.new(Binary) end diff --git a/lib/arel/nodes/select_statement.rb b/lib/arel/nodes/select_statement.rb index c9a0cde4e0..cd74dd8e28 100644 --- a/lib/arel/nodes/select_statement.rb +++ b/lib/arel/nodes/select_statement.rb @@ -2,15 +2,17 @@ module Arel module Nodes class SelectStatement < Arel::Nodes::Node attr_reader :cores - attr_accessor :limit, :orders, :lock, :offset + attr_accessor :limit, :orders, :lock, :offset, :with, :with_recursive def initialize cores = [SelectCore.new] #puts caller - @cores = cores - @orders = [] - @limit = nil - @lock = nil - @offset = nil + @cores = cores + @orders = [] + @limit = nil + @lock = nil + @offset = nil + @with = nil + @with_recursive = nil end def initialize_copy other diff --git a/lib/arel/nodes/with.rb b/lib/arel/nodes/with.rb new file mode 100644 index 0000000000..ce1644b60e --- /dev/null +++ b/lib/arel/nodes/with.rb @@ -0,0 +1,17 @@ +module Arel + module Nodes + class With < Arel::Nodes::Unary + attr_reader :children + alias value children + alias expr children + + def initialize *children + @children = children + end + + end + + class WithRecursive < With; end + end +end + -- cgit v1.2.3