aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-07-03 08:32:02 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-07-03 08:32:02 +0000
commit018e12da312a1ac35f23cf32155b61e21362fca4 (patch)
tree147b6b3295c271fc7b2c9bbcd68d8b1c2051de07 /activerecord/lib
parent121b15bfc957f7c7d6fe965c126936a72c80b1c9 (diff)
downloadrails-018e12da312a1ac35f23cf32155b61e21362fca4.tar.gz
rails-018e12da312a1ac35f23cf32155b61e21362fca4.tar.bz2
rails-018e12da312a1ac35f23cf32155b61e21362fca4.zip
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
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/locking.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/activerecord/lib/active_record/locking.rb b/activerecord/lib/active_record/locking.rb
index 90aba3913c..c8868bed3c 100644
--- a/activerecord/lib/active_record/locking.rb
+++ b/activerecord/lib/active_record/locking.rb
@@ -32,14 +32,15 @@ module ActiveRecord
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