提交 018e12da 编写于 作者: J Jeremy Kemper

r1605@asus: jeremy | 2005-07-02 14:50:23 -0700

 And take it out again.. passing around the quoter doesn't make sense any more because we're calling quote_column_name, not the generic quote method.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1624 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 121b15bf
......@@ -32,14 +32,15 @@ def update_with_lock #:nodoc:
previous_value = self.lock_version
self.lock_version = previous_value + 1
affected_rows = connection.update(
"UPDATE #{self.class.table_name} "+
"SET #{quoted_comma_pair_list(connection, attributes_with_quotes(false))} " +
"WHERE #{self.class.primary_key} = #{quote(id)} AND lock_version = #{quote(previous_value)}",
"#{self.class.name} Update with optimistic locking"
)
raise(ActiveRecord::StaleObjectError, "Attempted to update a stale object") unless affected_rows == 1
affected_rows = connection.update(<<-end_sql, "#{self.class.name} Update with optimistic locking")
UPDATE #{self.class.table_name}
SET #{quoted_comma_pair_list(attributes_with_quotes(false))}
WHERE #{self.class.primary_key} = #{quote(id)} AND lock_version = #{quote(previous_value)}
end_sql
unless affected_rows == 1
raise ActiveRecord::StaleObjectError, "Attempted to update a stale object"
end
else
update_without_lock
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册