Class: Arel::InsertManager
Do not use. This class is for internal use only.
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
TreeManager
|
|
Instance Chain:
self,
TreeManager ,
FactoryMethods
|
|
Inherits: |
Arel::TreeManager
|
Defined in: | activerecord/lib/arel/insert_manager.rb |
Class Method Summary
- .new(table = nil) ⇒ InsertManager constructor
Instance Attribute Summary
Instance Method Summary
- #columns
- #create_values(values)
- #create_values_list(rows)
- #insert(fields)
- #into(table)
- #select(select)
TreeManager
- Inherited
FactoryMethods
- Included
#cast, #coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, | |
#lower | Create a LOWER() function. |
Constructor Details
.new(table = nil) ⇒ InsertManager
# File 'activerecord/lib/arel/insert_manager.rb', line 5
def initialize(table = nil) @ast = Nodes::InsertStatement.new(table) end
Instance Attribute Details
#values=(val) (writeonly)
[ GitHub ]# File 'activerecord/lib/arel/insert_manager.rb', line 15
def values=(val); @ast.values = val; end
Instance Method Details
#columns
[ GitHub ]# File 'activerecord/lib/arel/insert_manager.rb', line 14
def columns; @ast.columns end
#create_values(values)
[ GitHub ]# File 'activerecord/lib/arel/insert_manager.rb', line 40
def create_values(values) Nodes::ValuesList.new([values]) end
#create_values_list(rows)
[ GitHub ]# File 'activerecord/lib/arel/insert_manager.rb', line 44
def create_values_list(rows) Nodes::ValuesList.new(rows) end
#insert(fields)
[ GitHub ]# File 'activerecord/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) end self end
#into(table)
[ GitHub ]# File 'activerecord/lib/arel/insert_manager.rb', line 9
def into(table) @ast.relation = table self end
#select(select)
[ GitHub ]# File 'activerecord/lib/arel/insert_manager.rb', line 17
def select(select) @ast.select = select end