mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
parent
005371e16c
commit
9a248a83b5
1 changed files with 3 additions and 3 deletions
|
@ -805,7 +805,7 @@ module ActiveRecord #:nodoc:
|
||||||
def update
|
def update
|
||||||
connection.update(
|
connection.update(
|
||||||
"UPDATE #{self.class.table_name} " +
|
"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}'",
|
"WHERE #{self.class.primary_key} = '#{id}'",
|
||||||
"#{self.class.name} Update"
|
"#{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
|
# Returns copy of the attributes hash where all the values have been safely quoted for use in
|
||||||
# an SQL statement.
|
# an SQL statement.
|
||||||
def attributes_with_quotes
|
def attributes_with_quotes(include_primary_key = true)
|
||||||
columns_hash = self.class.columns_hash
|
columns_hash = self.class.columns_hash
|
||||||
@attributes.inject({}) do |attrs_quoted, pair|
|
@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
|
attrs_quoted
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue