Permalink
Browse files

adding unary node

  • Loading branch information...
1 parent ad16c18 commit 963ca860d579a507effbe818da0c89bf443f33c9 @tenderlove tenderlove committed Nov 29, 2010
View
@@ -1,4 +1,5 @@
require 'arel/nodes/node'
+require 'arel/nodes/unary'
require 'arel/nodes/binary'
require 'arel/nodes/equality'
require 'arel/nodes/between'
@@ -1,11 +1,6 @@
module Arel
module Nodes
- class Group
- attr_accessor :expr
-
- def initialize expr
- @expr = expr
- end
+ class Group < Arel::Nodes::Unary
end
end
end
@@ -1,11 +1,6 @@
module Arel
module Nodes
- class Grouping < Arel::Nodes::Node
- attr_accessor :expr
-
- def initialize expression
- @expr = expression
- end
+ class Grouping < Arel::Nodes::Unary
end
end
end
@@ -1,11 +1,6 @@
module Arel
module Nodes
- class Having
- attr_accessor :expr
-
- def initialize expr
- @expr = expr
- end
+ class Having < Arel::Nodes::Unary
end
end
end
@@ -1,11 +1,7 @@
module Arel
module Nodes
- class Offset
- attr_accessor :value
-
- def initialize value
- @value = value
- end
+ class Offset < Arel::Nodes::Unary
+ alias :value :expr
end
end
end
@@ -1,10 +1,11 @@
module Arel
module Nodes
- class Ordering < Arel::Nodes::Node
- attr_accessor :expr, :direction
+ class Ordering < Arel::Nodes::Binary
+ alias :expr :left
+ alias :direction :right
- def initialize expression, direction = :asc
- @expr, @direction = expression, direction
+ def initialize expr, direction = :asc
+ super
end
def ascending?
@@ -0,0 +1,11 @@
+module Arel
+ module Nodes
+ class Unary < Arel::Nodes::Node
+ attr_accessor :expr
+
+ def initialize expr
+ @expr = expr
+ end
+ end
+ end
+end
@@ -97,7 +97,7 @@ def visit_Arel_Nodes_Having o
end
def visit_Arel_Nodes_Offset o
- "OFFSET #{visit o.value}"
+ "OFFSET #{visit o.expr}"
end
# FIXME: this does nothing on SQLLite3, but should do things on other
@@ -130,6 +130,9 @@ def test_insert_statement
@visitor.accept stmt
assert_equal [:a, :b, stmt.columns, :c, stmt], @collector.calls
end
+
+ def test_offset
+ end
end
end
end

0 comments on commit 963ca86

Please sign in to comment.