diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-27 13:12:15 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-27 13:12:15 -0700 |
commit | 77fa5fa5f7cc21824edb5b1c1ebccd58f92e982b (patch) | |
tree | 80c71416e19948b7e0c4c3b9aacd36672ab62d1d /lib/arel | |
parent | ec998ae9a6aeda09ad64bb94a50ac8b9fccd246d (diff) | |
download | rails-77fa5fa5f7cc21824edb5b1c1ebccd58f92e982b.tar.gz rails-77fa5fa5f7cc21824edb5b1c1ebccd58f92e982b.tar.bz2 rails-77fa5fa5f7cc21824edb5b1c1ebccd58f92e982b.zip |
to_sql on nodes may be passed an engine
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/nodes/binary.rb | 10 | ||||
-rw-r--r-- | lib/arel/nodes/function.rb | 7 | ||||
-rw-r--r-- | lib/arel/nodes/grouping.rb | 10 | ||||
-rw-r--r-- | lib/arel/nodes/node.rb | 10 |
4 files changed, 11 insertions, 26 deletions
diff --git a/lib/arel/nodes/binary.rb b/lib/arel/nodes/binary.rb index 090468adfa..cfa75909c5 100644 --- a/lib/arel/nodes/binary.rb +++ b/lib/arel/nodes/binary.rb @@ -7,16 +7,6 @@ module Arel @left = left @right = 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. - # - # Maybe we should just use `Table.engine`? :'( - def to_sql - viz = Visitors::ToSql.new Table.engine - viz.accept self - end end end end diff --git a/lib/arel/nodes/function.rb b/lib/arel/nodes/function.rb index a1cd13d4d1..133dd66019 100644 --- a/lib/arel/nodes/function.rb +++ b/lib/arel/nodes/function.rb @@ -1,6 +1,6 @@ module Arel module Nodes - class Function + class Function < Arel::Nodes::Node include Arel::Expression attr_accessor :expressions, :alias @@ -13,11 +13,6 @@ module Arel self.alias = SqlLiteral.new(aliaz) self end - - def to_sql - viz = Visitors::ToSql.new Table.engine - viz.accept self - end end end end diff --git a/lib/arel/nodes/grouping.rb b/lib/arel/nodes/grouping.rb index 0af1df1f7a..d52671f169 100644 --- a/lib/arel/nodes/grouping.rb +++ b/lib/arel/nodes/grouping.rb @@ -6,16 +6,6 @@ module Arel def initialize expression @expr = expression 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. - # - # Maybe we should just use `Table.engine`? :'( - def to_sql - viz = Visitors::ToSql.new Table.engine - viz.accept self - end end end end diff --git a/lib/arel/nodes/node.rb b/lib/arel/nodes/node.rb index fd5ea410ea..91c0a32573 100644 --- a/lib/arel/nodes/node.rb +++ b/lib/arel/nodes/node.rb @@ -15,6 +15,16 @@ module Arel def and right Nodes::And.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. + # + # Maybe we should just use `Table.engine`? :'( + def to_sql engine = Table.engine + viz = Visitors::ToSql.new engine + viz.accept self + end end end end |