aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-12-01 15:20:53 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-12-01 15:20:53 +0000
commit9a248a83b5b129ed589f8d829b6ce7316bc1a272 (patch)
treec289e589d5cbbaa5a7cc25b5eda9307b13051781
parent005371e16cf214509bb988dcf5d0eef3ee23157d (diff)
downloadrails-9a248a83b5b129ed589f8d829b6ce7316bc1a272.tar.gz
rails-9a248a83b5b129ed589f8d829b6ce7316bc1a272.tar.bz2
rails-9a248a83b5b129ed589f8d829b6ce7316bc1a272.zip
Dont include the primary key in updates -- its unneeded and SQL Server chokes on it
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@42 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rwxr-xr-xactiverecord/lib/active_record/base.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 3908ea8e4e..8b09c60c53 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -805,7 +805,7 @@ module ActiveRecord #:nodoc:
def update
connection.update(
"UPDATE #{self.class.table_name} " +
- "SET #{quoted_comma_pair_list(connection, attributes_with_quotes)} " +
+ "SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " +
"WHERE #{self.class.primary_key} = '#{id}'",
"#{self.class.name} Update"
)
@@ -941,10 +941,10 @@ module ActiveRecord #:nodoc:
# Returns copy of the attributes hash where all the values have been safely quoted for use in
# an SQL statement.
- def attributes_with_quotes
+ def attributes_with_quotes(include_primary_key = true)
columns_hash = self.class.columns_hash
@attributes.inject({}) do |attrs_quoted, pair|
- attrs_quoted[pair.first] = quote(pair.last, columns_hash[pair.first])
+ attrs_quoted[pair.first] = quote(pair.last, columns_hash[pair.first]) unless !include_primary_key && pair.first == self.class.primary_key
attrs_quoted
end
end