Sha256: 8bfcdbb0d6aa64597709a9255803f134b234204e6a85f44f04919897d77ee7f5
Contents?: true
Size: 1007 Bytes
Versions: 23
Compression:
Stored size: 1007 Bytes
Contents
# frozen_string_literal: true module Arel # :nodoc: all class UpdateManager < Arel::TreeManager include TreeManager::StatementMethods def initialize(table = nil) @ast = Nodes::UpdateStatement.new(table) end ### # UPDATE +table+ def table(table) @ast.relation = table self end 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 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 def having(expr) @ast.havings << expr self end end end
Version data entries
23 entries across 23 versions & 2 rubygems
Version | Path |
---|---|
activerecord-7.2.0.beta3 | lib/arel/update_manager.rb |
activerecord-7.2.0.beta2 | lib/arel/update_manager.rb |
activerecord-7.2.0.beta1 | lib/arel/update_manager.rb |