diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-16 17:26:12 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-08-16 17:26:12 -0700 |
commit | ae547dc139179720a814ae21f43f3e0aaad97c5c (patch) | |
tree | 8e3b12ee400c200067676511f976e36486f74fba /lib/arel/nodes | |
parent | 66243e491d06edf0bff21000adad2837e67c21e2 (diff) | |
download | rails-ae547dc139179720a814ae21f43f3e0aaad97c5c.tar.gz rails-ae547dc139179720a814ae21f43f3e0aaad97c5c.tar.bz2 rails-ae547dc139179720a814ae21f43f3e0aaad97c5c.zip |
OR nodes are somewhat working
Diffstat (limited to 'lib/arel/nodes')
-rw-r--r-- | lib/arel/nodes/binary.rb | 24 | ||||
-rw-r--r-- | lib/arel/nodes/equality.rb | 13 | ||||
-rw-r--r-- | lib/arel/nodes/or.rb | 6 |
3 files changed, 31 insertions, 12 deletions
diff --git a/lib/arel/nodes/binary.rb b/lib/arel/nodes/binary.rb new file mode 100644 index 0000000000..44204d91e0 --- /dev/null +++ b/lib/arel/nodes/binary.rb @@ -0,0 +1,24 @@ +module Arel + module Nodes + class Binary + attr_accessor :left, :right + + def initialize left, right + @left = left + @right = right + end + + def or right + Nodes::Or.new self, right + end + + # FIXME: this method should go away. I don't like people calling + # to_sql on non-head nodes. This forces us to walk the AST until we + # can find a node that has a "relation" member. + def to_sql + viz = Visitors::ToSql.new left.relation.engine + viz.accept self + end + end + end +end diff --git a/lib/arel/nodes/equality.rb b/lib/arel/nodes/equality.rb index d778380054..b8d8281434 100644 --- a/lib/arel/nodes/equality.rb +++ b/lib/arel/nodes/equality.rb @@ -1,17 +1,6 @@ module Arel module Nodes - class Equality - attr_accessor :left, :right - - def initialize left, right - @left = left - @right = right - end - - def to_sql - viz = Visitors::ToSql.new left.relation.engine - viz.accept self - end + class Equality < Arel::Nodes::Binary end end end diff --git a/lib/arel/nodes/or.rb b/lib/arel/nodes/or.rb new file mode 100644 index 0000000000..bdf7f6d9b3 --- /dev/null +++ b/lib/arel/nodes/or.rb @@ -0,0 +1,6 @@ +module Arel + module Nodes + class Or < Arel::Nodes::Binary + end + end +end |