Class: Arel::UpdateManager
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:
|
|
Inherits: |
Arel::TreeManager
|
Defined in: | activerecord/lib/arel/update_manager.rb |
Class Method Summary
- .new(table = nil) ⇒ UpdateManager constructor
Instance Attribute Summary
Instance Method Summary
- #group(columns)
- #having(expr)
- #set(values)
-
#table(table)
UPDATE
table
.
TreeManager::StatementMethods
- Included
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) ⇒ UpdateManager
# File 'activerecord/lib/arel/update_manager.rb', line 7
def initialize(table = nil) @ast = Nodes::UpdateStatement.new(table) end
Instance Method Details
#group(columns)
[ GitHub ]# File 'activerecord/lib/arel/update_manager.rb', line 33
def group(columns) columns.each do |column| column = Nodes::SqlLiteral.new(column) if String === column column = Nodes::SqlLiteral.new(column.to_s) if Symbol === column @ast.groups.push Nodes::Group.new column end self end
#having(expr)
[ GitHub ]# File 'activerecord/lib/arel/update_manager.rb', line 44
def having(expr) @ast.havings << expr self end
#set(values)
[ GitHub ]# File 'activerecord/lib/arel/update_manager.rb', line 18
def set(values) case values when String, Nodes::BoundSqlLiteral @ast.values = [values] else @ast.values = values.map { |column, value| Nodes::Assignment.new( Nodes::UnqualifiedColumn.new(column), value ) } end self end
#table(table)
UPDATE table
# File 'activerecord/lib/arel/update_manager.rb', line 13
def table(table) @ast.relation = table self end