diff options
author | Emilio Tagua <miloops@gmail.com> | 2009-08-18 16:28:04 -0300 |
---|---|---|
committer | Emilio Tagua <miloops@gmail.com> | 2009-08-18 16:28:04 -0300 |
commit | fefb4c78ac8f37ea0b14cbb0c008f305a1bbd36f (patch) | |
tree | ceda4f952ae6182a4495a41ca3a6dbc962ee5df8 /activerecord/lib/active_record/locking | |
parent | 0d6997b6e3f25d87b08b4aacaa2140609d5cc19c (diff) | |
download | rails-fefb4c78ac8f37ea0b14cbb0c008f305a1bbd36f.tar.gz rails-fefb4c78ac8f37ea0b14cbb0c008f305a1bbd36f.tar.bz2 rails-fefb4c78ac8f37ea0b14cbb0c008f305a1bbd36f.zip |
Cache arel_table when possible, use class method arel_table instead
instance method.
Diffstat (limited to 'activerecord/lib/active_record/locking')
-rw-r--r-- | activerecord/lib/active_record/locking/optimistic.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index 4e833ec871..c8cd79a2b0 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -89,7 +89,9 @@ module ActiveRecord attribute_names.uniq! begin - affected_rows = arel_table(true).where( + arel_table = self.class.arel_table(self.class.table_name) + + affected_rows = arel_table.where( arel_table[self.class.primary_key].eq(quoted_id).and( arel_table[self.class.locking_column].eq(quote_value(previous_value)) ) @@ -116,7 +118,9 @@ module ActiveRecord lock_col = self.class.locking_column previous_value = send(lock_col).to_i - affected_rows = arel_table(true).where( + arel_table = self.class.arel_table(self.class.table_name) + + affected_rows = arel_table.where( arel_table[self.class.primary_key].eq(quoted_id).and( arel_table[self.class.locking_column].eq(quote_value(previous_value)) ) |