1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

removing more calls to deprecated methods

This commit is contained in:
Aaron Patterson 2010-12-02 14:49:02 -08:00
parent 12b9920a15
commit ead0c6eed3
3 changed files with 7 additions and 4 deletions

View file

@ -67,9 +67,10 @@ module ActiveRecord
@reflection.klass.delete(records.map { |record| record.id })
else
relation = Arel::Table.new(@reflection.table_name)
relation.where(relation[@reflection.primary_key_name].eq(@owner.id).
stmt = relation.where(relation[@reflection.primary_key_name].eq(@owner.id).
and(relation[@reflection.klass.primary_key].in(records.map { |r| r.id }))
).update(relation[@reflection.primary_key_name] => nil)
).compile_update(relation[@reflection.primary_key_name] => nil)
@owner.connection.update stmt.to_sql
@owner.class.update_counters(@owner.id, cached_counter_attribute_name => -records.size) if has_cached_counter?
end

View file

@ -30,9 +30,10 @@ module ActiveRecord
reflection = belongs_to.find { |e| e.class_name == expected_name }
counter_name = reflection.counter_cache_column
self.unscoped.where(arel_table[self.primary_key].eq(object.id)).arel.update({
stmt = unscoped.where(arel_table[primary_key].eq(object.id)).arel.compile_update({
arel_table[counter_name] => object.send(association).count
})
connection.update stmt.to_sql
end
return true
end

View file

@ -156,7 +156,8 @@ module ActiveRecord
else
# Apply limit and order only if they're both present
if @limit_value.present? == @order_values.present?
arel.update(Arel::SqlLiteral.new(@klass.send(:sanitize_sql_for_assignment, updates)))
stmt = arel.compile_update(Arel::SqlLiteral.new(@klass.send(:sanitize_sql_for_assignment, updates)))
@klass.connection.update stmt.to_sql
else
except(:limit, :order).update_all(updates)
end