Skip to content
This repository
Browse code

insert statements supported

  • Loading branch information...
commit ad16c18cc3a7db4b56611b9244140f0b495a1214 1 parent 4b91cbc
Aaron Patterson tenderlove authored
2  lib/arel/nodes/insert_statement.rb
... ... @@ -1,6 +1,6 @@
1 1 module Arel
2 2 module Nodes
3   - class InsertStatement
  3 + class InsertStatement < Arel::Nodes::Node
4 4 attr_accessor :relation, :columns, :values
5 5
6 6 def initialize
2  lib/arel/nodes/select_statement.rb
... ... @@ -1,6 +1,6 @@
1 1 module Arel
2 2 module Nodes
3   - class SelectStatement
  3 + class SelectStatement < Arel::Nodes::Node
4 4 attr_reader :cores
5 5 attr_accessor :limit, :orders, :lock, :offset
6 6
7 lib/arel/visitors/depth_first.rb
@@ -61,6 +61,13 @@ def terminal o
61 61 alias :visit_Time :terminal
62 62 alias :visit_TrueClass :terminal
63 63
  64 + def visit_Arel_Nodes_InsertStatement o
  65 + visit o.relation
  66 + visit o.columns
  67 + visit o.values
  68 + @block.call o
  69 + end
  70 +
64 71 def visit_Arel_Nodes_SelectCore o
65 72 visit o.projections
66 73 visit o.froms
10 test/visitors/test_depth_first.rb
@@ -120,6 +120,16 @@ def test_select_statement
120 120 :e,
121 121 ss], @collector.calls
122 122 end
  123 +
  124 + def test_insert_statement
  125 + stmt = Nodes::InsertStatement.new
  126 + stmt.relation = :a
  127 + stmt.columns << :b
  128 + stmt.values = :c
  129 +
  130 + @visitor.accept stmt
  131 + assert_equal [:a, :b, stmt.columns, :c, stmt], @collector.calls
  132 + end
123 133 end
124 134 end
125 135 end

0 comments on commit ad16c18

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