Class: Arel::UpdateManager
- Inherits:
-
TreeManager
- Object
- TreeManager
- Arel::UpdateManager
- Includes:
- TreeManager::StatementMethods
- Defined in:
- lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/update_manager.rb
Instance Attribute Summary
Attributes inherited from TreeManager
Instance Method Summary collapse
- #group(columns) ⇒ Object
- #having(expr) ⇒ Object
-
#initialize(table = nil) ⇒ UpdateManager
constructor
A new instance of UpdateManager.
- #set(values) ⇒ Object
-
#table(table) ⇒ Object
UPDATE
table
.
Methods included from TreeManager::StatementMethods
#key, #key=, #offset, #order, #take, #where, #wheres=
Methods inherited from TreeManager
#initialize_copy, #to_dot, #to_sql
Methods included from FactoryMethods
#coalesce, #create_and, #create_false, #create_join, #create_on, #create_string_join, #create_table_alias, #create_true, #grouping, #lower
Constructor Details
#initialize(table = nil) ⇒ UpdateManager
Returns a new instance of UpdateManager.
7 8 9 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/update_manager.rb', line 7 def initialize(table = nil) @ast = Nodes::UpdateStatement.new(table) end |
Instance Method Details
#group(columns) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/update_manager.rb', line 32 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) ⇒ Object
43 44 45 46 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/update_manager.rb', line 43 def having(expr) @ast.havings << expr self end |
#set(values) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/update_manager.rb', line 18 def set(values) if String === values @ast.values = [values] else @ast.values = values.map { |column, value| Nodes::Assignment.new( Nodes::UnqualifiedColumn.new(column), value ) } end self end |
#table(table) ⇒ Object
UPDATE table
13 14 15 16 |
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/activerecord-7.0.4/lib/arel/update_manager.rb', line 13 def table(table) @ast.relation = table self end |