Permalink
Browse files

update statement supported

  • Loading branch information...
tenderlove committed Nov 29, 2010
1 parent c86c37e commit 20cd623aba6cc0c1b08b7d6fcf277633cfe236d4
Showing with 22 additions and 0 deletions.
  1. +9 −0 lib/arel/visitors/depth_first.rb
  2. +13 −0 test/visitors/test_depth_first.rb
@@ -61,6 +61,15 @@ def terminal o
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
@@ -71,6 +71,19 @@ def test_hash
@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

0 comments on commit 20cd623

Please sign in to comment.