diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-31 01:10:04 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-03-31 01:10:04 +0000 |
commit | 6b9448cdd227ef3adbe2f31ecaf64bc7ef062103 (patch) | |
tree | 6814f2520554eef1b7ed69e4e284db44d00d7fd9 /activerecord/lib/active_record/base.rb | |
parent | 2cf72ad250f7c393e6aa97384768ed803686eb97 (diff) | |
download | rails-6b9448cdd227ef3adbe2f31ecaf64bc7ef062103.tar.gz rails-6b9448cdd227ef3adbe2f31ecaf64bc7ef062103.tar.bz2 rails-6b9448cdd227ef3adbe2f31ecaf64bc7ef062103.zip |
Partial updates include only unsaved attributes. Off by default; set YourClass.partial_updates = true to enable.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9157 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/base.rb')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index af480a0797..fe38454226 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2407,8 +2407,8 @@ module ActiveRecord #:nodoc: # Updates the associated record with values matching those of the instance attributes. # Returns the number of affected rows. - def update - quoted_attributes = attributes_with_quotes(false, false) + def update(attribute_names = @attributes.keys) + quoted_attributes = attributes_with_quotes(false, false, attribute_names) return 0 if quoted_attributes.empty? connection.update( "UPDATE #{self.class.quoted_table_name} " + @@ -2500,10 +2500,10 @@ module ActiveRecord #:nodoc: # Returns a copy of the attributes hash where all the values have been safely quoted for use in # an SQL statement. - def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true) + def attributes_with_quotes(include_primary_key = true, include_readonly_attributes = true, attribute_names = @attributes.keys) quoted = {} connection = self.class.connection - @attributes.each_pair do |name, value| + attribute_names.each do |name| if column = column_for_attribute(name) quoted[name] = connection.quote(read_attribute(name), column) unless !include_primary_key && column.primary end |