aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/arel/visitors/depth_first.rb9
-rw-r--r--test/visitors/test_depth_first.rb13
2 files changed, 22 insertions, 0 deletions
diff --git a/lib/arel/visitors/depth_first.rb b/lib/arel/visitors/depth_first.rb
index 19796b6e72..8ff4b4d162 100644
--- a/lib/arel/visitors/depth_first.rb
+++ b/lib/arel/visitors/depth_first.rb
@@ -61,6 +61,15 @@ module Arel
alias :visit_Time :terminal
alias :visit_TrueClass :terminal
+ def visit_Arel_Nodes_UpdateStatement o
+ visit o.relation
+ visit o.values
+ visit o.wheres
+ visit o.orders
+ visit o.limit
+ @block.call o
+ end
+
def visit_Array o
o.each { |i| visit i }
@block.call o
diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb
index eff60576fc..fd91dd5fb9 100644
--- a/test/visitors/test_depth_first.rb
+++ b/test/visitors/test_depth_first.rb
@@ -71,6 +71,19 @@ module Arel
@visitor.accept hash
assert_equal [:a, :b, node, :a, :b, node, hash], @collector.calls
end
+
+ def test_update_statement
+ stmt = Nodes::UpdateStatement.new
+ stmt.relation = :a
+ stmt.values << :b
+ stmt.wheres << :c
+ stmt.orders << :d
+ stmt.limit = :e
+
+ @visitor.accept stmt
+ assert_equal [:a, :b, stmt.values, :c, stmt.wheres, :d, stmt.orders,
+ :e, stmt], @collector.calls
+ end
end
end
end