Class: Arel::InsertManager
Instance Attribute Summary
Attributes inherited from TreeManager
#ast, #bind_values, #engine
Instance Method Summary
collapse
Methods inherited from TreeManager
#initialize_copy, #to_dot, #to_sql, #where
#create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower
Constructor Details
Returns a new instance of InsertManager.
Instance Method Details
#columns ⇒ Object
14
|
# File 'lib/arel/insert_manager.rb', line 14
def columns; @ast.columns end
|
#create_values(values, columns) ⇒ Object
39
40
41
|
# File 'lib/arel/insert_manager.rb', line 39
def create_values values, columns
Nodes::Values.new values, columns
end
|
#insert(fields) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/arel/insert_manager.rb', line 21
def insert fields
return if fields.empty?
if String === fields
@ast.values = Nodes::SqlLiteral.new(fields)
else
@ast.relation ||= fields.first.first.relation
values = []
fields.each do |column, value|
@ast.columns << column
values << value
end
@ast.values = create_values values, @ast.columns
end
end
|
#into(table) ⇒ Object
9
10
11
12
|
# File 'lib/arel/insert_manager.rb', line 9
def into table
@ast.relation = table
self
end
|
#select(select) ⇒ Object
17
18
19
|
# File 'lib/arel/insert_manager.rb', line 17
def select select
@ast.select = select
end
|
#values=(val) ⇒ Object
15
|
# File 'lib/arel/insert_manager.rb', line 15
def values= val; @ast.values = val; end
|