diff options
Diffstat (limited to 'lib/arel')
-rw-r--r-- | lib/arel/delete_manager.rb | 6 | ||||
-rw-r--r-- | lib/arel/predications.rb | 4 | ||||
-rw-r--r-- | lib/arel/select_manager.rb | 5 | ||||
-rw-r--r-- | lib/arel/tree_manager.rb | 9 | ||||
-rw-r--r-- | lib/arel/update_manager.rb | 1 | ||||
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 4 |
6 files changed, 13 insertions, 16 deletions
diff --git a/lib/arel/delete_manager.rb b/lib/arel/delete_manager.rb index 3aab248c23..b4c61f708f 100644 --- a/lib/arel/delete_manager.rb +++ b/lib/arel/delete_manager.rb @@ -3,6 +3,7 @@ module Arel def initialize engine super @ast = Nodes::DeleteStatement.new + @ctx = @ast end def from relation @@ -10,11 +11,6 @@ module Arel self end - def where expression - @ast.wheres << expression - self - end - def wheres= list @ast.wheres = list end diff --git a/lib/arel/predications.rb b/lib/arel/predications.rb index dec4392f0f..23e68e99f1 100644 --- a/lib/arel/predications.rb +++ b/lib/arel/predications.rb @@ -31,7 +31,7 @@ module Arel def in other case other when Arel::SelectManager - Arel::Nodes::In.new(self, other) + Arel::Nodes::In.new(self, other.ast) when Range if other.exclude_end? left = Nodes::GreaterThanOrEqual.new(self, other.begin) @@ -56,7 +56,7 @@ module Arel def not_in other case other when Arel::SelectManager - Arel::Nodes::NotIn.new(self, other) + Arel::Nodes::NotIn.new(self, other.ast) when Range if other.exclude_end? left = Nodes::LessThan.new(self, other.begin) diff --git a/lib/arel/select_manager.rb b/lib/arel/select_manager.rb index 08cfd41e7f..10d23378ae 100644 --- a/lib/arel/select_manager.rb +++ b/lib/arel/select_manager.rb @@ -107,11 +107,6 @@ module Arel self end - def where expr - @ctx.wheres << expr - self - end - def order *expr # FIXME: We SHOULD NOT be converting these to SqlLiteral automatically @ast.orders.concat expr.map { |x| diff --git a/lib/arel/tree_manager.rb b/lib/arel/tree_manager.rb index 6176f8a250..2fa770a0e3 100644 --- a/lib/arel/tree_manager.rb +++ b/lib/arel/tree_manager.rb @@ -9,6 +9,7 @@ module Arel def initialize engine @engine = engine @visitor = Visitors.visitor_for @engine + @ctx = nil end def to_dot @@ -23,5 +24,13 @@ module Arel super @ast = @ast.clone end + + def where expr + if Arel::TreeManager === expr + expr = expr.ast + end + @ctx.wheres << expr + self + end end end diff --git a/lib/arel/update_manager.rb b/lib/arel/update_manager.rb index c0fb4fbd5f..821dce7d81 100644 --- a/lib/arel/update_manager.rb +++ b/lib/arel/update_manager.rb @@ -3,6 +3,7 @@ module Arel def initialize engine super @ast = Nodes::UpdateStatement.new + @ctx = @ast end def take limit diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 6fc206c12c..a2105d7043 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -72,10 +72,6 @@ module Arel }.join ', '})" end - def visit_Arel_SelectManager o - o.to_sql - end - def visit_Arel_Nodes_SelectStatement o [ o.cores.map { |x| visit_Arel_Nodes_SelectCore x }.join, |