def update_all(updates)
      raise ArgumentError, "Empty list of attributes to change" if updates.blank?

      if eager_loading?
        relation = apply_join_dependency
        return relation.update_all(updates)
      end

      stmt = Arel::UpdateManager.new
      stmt.table(arel.join_sources.empty? ? table : arel.source)
      stmt.key = arel_attribute(primary_key)
      stmt.take(arel.limit)
      stmt.offset(arel.offset)
      stmt.order(*arel.orders)
      stmt.wheres = arel.constraints

      if updates.is_a?(Hash)
        if klass.locking_enabled? &&
            !updates.key?(klass.locking_column) &&
            !updates.key?(klass.locking_column.to_sym)
          attr = arel_attribute(klass.locking_column)
          updates[attr.name] = _increment_attribute(attr)
        end
        stmt.set _substitute_values(updates)
      else
        stmt.set Arel.sql(klass.sanitize_sql_for_assignment(updates, table.name))
      end

      @klass.connection.update stmt, "#{@klass} Update All"
    end
def update_all(updates)
      raise ArgumentError, "Empty list of attributes to change" if updates.blank?

      if eager_loading?
        relation = apply_join_dependency
        return relation.update_all(updates)
      end

      stmt = Arel::UpdateManager.new
      stmt.table(arel.join_sources.empty? ? table : arel.source)
      stmt.key = arel_attribute(primary_key)
      stmt.take(arel.limit)
      stmt.offset(arel.offset)
      stmt.order(*arel.orders)
      stmt.wheres = arel.constraints

      if updates.is_a?(Hash)
        if klass.locking_enabled? &&
            !updates.key?(klass.locking_column) &&
            !updates.key?(klass.locking_column.to_sym)
          attr = arel_attribute(klass.locking_column)
          updates[attr.name] = _increment_attribute(attr)
        end
        stmt.set _substitute_values(updates)
      else
        stmt.set Arel.sql(klass.sanitize_sql_for_assignment(updates, table.name))
      end

      @klass.connection.update stmt, "#{@klass} Update All"
    end
Updates all records in the current relation with details given. This method constructs a single SQL UPDATE
 statement and sends it straight to the database. It does not instantiate the involved models and it does not
 trigger Active Record callbacks or validations. However, values passed to #update_all will still go through
 Active Record's normal type casting and serialization.

 Note: As Active Record callbacks are not triggered, this method will not automatically update +updated_at+/+updated_on+ columns.

 ==== Parameters

 * +updates+ - A string, array, or hash representing the SET part of an SQL statement.

 ==== Examples

   # Update all customers with the given attributes
   Customer.update_all wants_email: true

   # Update all books with 'Rails' in their title
   Book.where('title LIKE ?', '%Rails%').update_all(author: 'David')

   # Update all books that match conditions, but limit it to 5 ordered by date
   Book.where('title LIKE ?', '%Rails%').order(:created_at).limit(5).update_all(author: 'David')

   # Update all invoices and set the number column to its id value.
   Invoice.update_all('number = id')