diff options
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/nodes.rb | 1 | ||||
-rw-r--r-- | lib/arel/nodes/group.rb | 7 | ||||
-rw-r--r-- | lib/arel/nodes/grouping.rb | 7 | ||||
-rw-r--r-- | lib/arel/nodes/having.rb | 7 | ||||
-rw-r--r-- | lib/arel/nodes/offset.rb | 8 | ||||
-rw-r--r-- | lib/arel/nodes/ordering.rb | 9 | ||||
-rw-r--r-- | lib/arel/nodes/unary.rb | 11 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 2 |
8 files changed, 23 insertions, 29 deletions
diff --git a/lib/arel/nodes.rb b/lib/arel/nodes.rb index 95dcc0480e..c454152d0d 100644 --- a/lib/arel/nodes.rb +++ b/lib/arel/nodes.rb @@ -1,4 +1,5 @@ require 'arel/nodes/node' +require 'arel/nodes/unary' require 'arel/nodes/binary' require 'arel/nodes/equality' require 'arel/nodes/between' diff --git a/lib/arel/nodes/group.rb b/lib/arel/nodes/group.rb index 57a7c579da..a7fa6f170d 100644 --- a/lib/arel/nodes/group.rb +++ b/lib/arel/nodes/group.rb @@ -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 diff --git a/lib/arel/nodes/grouping.rb b/lib/arel/nodes/grouping.rb index d52671f169..18adeae97f 100644 --- a/lib/arel/nodes/grouping.rb +++ b/lib/arel/nodes/grouping.rb @@ -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 diff --git a/lib/arel/nodes/having.rb b/lib/arel/nodes/having.rb index 1944a84391..6972c58dda 100644 --- a/lib/arel/nodes/having.rb +++ b/lib/arel/nodes/having.rb @@ -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 diff --git a/lib/arel/nodes/offset.rb b/lib/arel/nodes/offset.rb index baa4068d93..d93e46aa1f 100644 --- a/lib/arel/nodes/offset.rb +++ b/lib/arel/nodes/offset.rb @@ -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 diff --git a/lib/arel/nodes/ordering.rb b/lib/arel/nodes/ordering.rb index d395c8631d..0a3621cf54 100644 --- a/lib/arel/nodes/ordering.rb +++ b/lib/arel/nodes/ordering.rb @@ -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? diff --git a/lib/arel/nodes/unary.rb b/lib/arel/nodes/unary.rb new file mode 100644 index 0000000000..edda89e1f0 --- /dev/null +++ b/lib/arel/nodes/unary.rb @@ -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 diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index ae90c0c4b6..abec5317ca 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -97,7 +97,7 @@ module Arel 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 |