1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

insert statements supported

This commit is contained in:
Aaron Patterson 2010-11-29 14:30:06 -08:00
parent 4b91cbc688
commit ad16c18cc3
4 changed files with 19 additions and 2 deletions

View file

@ -1,6 +1,6 @@
module Arel
module Nodes
class InsertStatement
class InsertStatement < Arel::Nodes::Node
attr_accessor :relation, :columns, :values
def initialize

View file

@ -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 file

@ -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

View file

@ -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