diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index fad83cde09c6957716fe74e61c8abd99b9d8b346..9ac8fcb176ca3989693f2749d983a122be5e1a3c 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -251,7 +251,8 @@ def update(attribute_names = @attributes.keys) attributes_with_values = arel_attributes_values(false, false, attribute_names) return 0 if attributes_with_values.empty? klass = self.class - klass.unscoped.where(klass.arel_table[klass.primary_key].eq(id)).arel.update(attributes_with_values) + stmt = klass.unscoped.where(klass.arel_table[klass.primary_key].eq(id)).arel.compile_update(attributes_with_values) + klass.connection.update stmt.to_sql end # Creates a record with values matching those of the instance attributes