Skip to content
Browse files

insert statements supported

  • Loading branch information...
1 parent 4b91cbc commit ad16c18cc3a7db4b56611b9244140f0b495a1214 @tenderlove tenderlove committed Nov 29, 2010
View
2 lib/arel/nodes/insert_statement.rb
@@ -1,6 +1,6 @@
module Arel
module Nodes
- class InsertStatement
+ class InsertStatement < Arel::Nodes::Node
attr_accessor :relation, :columns, :values
def initialize
View
2 lib/arel/nodes/select_statement.rb
@@ -1,6 +1,6 @@
module Arel
module Nodes
- class SelectStatement
+ class SelectStatement < Arel::Nodes::Node
attr_reader :cores
attr_accessor :limit, :orders, :lock, :offset
View
7 lib/arel/visitors/depth_first.rb
@@ -61,6 +61,13 @@ def terminal o
alias :visit_Time :terminal
alias :visit_TrueClass :terminal
+ def visit_Arel_Nodes_InsertStatement o
+ visit o.relation
+ visit o.columns
+ visit o.values
+ @block.call o
+ end
+
def visit_Arel_Nodes_SelectCore o
visit o.projections
visit o.froms
View
10 test/visitors/test_depth_first.rb
@@ -120,6 +120,16 @@ def test_select_statement
:e,
ss], @collector.calls
end
+
+ def test_insert_statement
+ stmt = Nodes::InsertStatement.new
+ stmt.relation = :a
+ stmt.columns << :b
+ stmt.values = :c
+
+ @visitor.accept stmt
+ assert_equal [:a, :b, stmt.columns, :c, stmt], @collector.calls
+ end
end
end
end

0 comments on commit ad16c18

Please sign in to comment.
Something went wrong with that request. Please try again.