<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -90,18 +90,20 @@ module ActiveRecord
 
           begin
             table = Arel(self.class.table_name)
-            affected_rows = table.where(
-              table[self.class.primary_key].eq(quoted_id).and(
-                table[self.class.locking_column].eq(quote_value(previous_value))
-              )
-            )
 
             attributes = {}
             attributes_with_quotes(false, false, attribute_names).map { |k,v|
               attributes.merge!(table[k] =&gt; v)
             }
 
-            unless affected_rows.update(attributes) == 1
+            affected_rows = table.where(
+              table[self.class.primary_key].eq(quoted_id).and(
+                table[self.class.locking_column].eq(quote_value(previous_value))
+              )
+            ).update(attributes)
+
+
+            unless affected_rows == 1
               raise ActiveRecord::StaleObjectError, &quot;Attempted to update a stale object&quot;
             end
 
@@ -121,7 +123,7 @@ module ActiveRecord
       lock_col = self.class.locking_column
       previous_value = send(lock_col).to_i
 
-      table = Arel(self.class.table_name, connection)
+      table = Arel(self.class.table_name)
       affected_rows = table.where(
           table[self.class.primary_key].eq(quoted_id).and(
           table[self.class.locking_column].eq(quote_value(previous_value))</diff>
      <filename>activerecord/lib/active_record/locking/optimistic.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>649fd1058f00fe0471d7d97bd659d0dc8c91ef22</id>
    </parent>
  </parents>
  <author>
    <name>Emilio Tagua</name>
    <email>miloops@gmail.com</email>
  </author>
  <url>http://github.com/findsyou/rails/commit/0e113a040d934958ce3805ce6cda73c655def444</url>
  <id>0e113a040d934958ce3805ce6cda73c655def444</id>
  <committed-date>2009-04-24T13:32:16-07:00</committed-date>
  <authored-date>2009-04-24T13:32:16-07:00</authored-date>
  <message>Refactored locking update</message>
  <tree>d8de5ee5f731c9a3d97b5e2e18e07b270753ef2c</tree>
  <committer>
    <name>Emilio Tagua</name>
    <email>miloops@gmail.com</email>
  </committer>
</commit>
