diff --git a/lib/arel/nodes/insert_statement.rb b/lib/arel/nodes/insert_statement.rb index a5e1a0bb9b..37c12f011a 100644 --- a/lib/arel/nodes/insert_statement.rb +++ b/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 diff --git a/lib/arel/nodes/select_statement.rb b/lib/arel/nodes/select_statement.rb index 371fd7bf21..6881a66747 100644 --- a/lib/arel/nodes/select_statement.rb +++ b/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 diff --git a/lib/arel/visitors/depth_first.rb b/lib/arel/visitors/depth_first.rb index 534f9edaf5..d6d3984ce2 100644 --- a/lib/arel/visitors/depth_first.rb +++ b/lib/arel/visitors/depth_first.rb @@ -61,6 +61,13 @@ module Arel 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 diff --git a/test/visitors/test_depth_first.rb b/test/visitors/test_depth_first.rb index 04c5096f5b..32778f7d4b 100644 --- a/test/visitors/test_depth_first.rb +++ b/test/visitors/test_depth_first.rb @@ -120,6 +120,16 @@ module Arel :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