diff options
author | Emilio Tagua <miloops@gmail.com> | 2010-11-25 15:36:08 -0300 |
---|---|---|
committer | Santiago Pastorino <santiago@wyeworks.com> | 2010-11-25 17:32:16 -0200 |
commit | c4d31d0f13783f3cfadbde666fd2a06996b456a2 (patch) | |
tree | 78d1b4a09bc67ebe7fc67776e6fc9aea6826ffea /activerecord | |
parent | 731ca00b484379661786fac36c17db7e085603c4 (diff) | |
download | rails-c4d31d0f13783f3cfadbde666fd2a06996b456a2.tar.gz rails-c4d31d0f13783f3cfadbde666fd2a06996b456a2.tar.bz2 rails-c4d31d0f13783f3cfadbde666fd2a06996b456a2.zip |
Reuse lock_col variable instead calling locking_column class method.
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/locking/optimistic.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index 9e1a33a6bf..6503004e38 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -89,7 +89,7 @@ module ActiveRecord affected_rows = relation.where( relation.table[self.class.primary_key].eq(quoted_id).and( - relation.table[self.class.locking_column].eq(quote_value(previous_value)) + relation.table[lock_col].eq(quote_value(previous_value)) ) ).arel.update(arel_attributes_values(false, false, attribute_names)) @@ -111,8 +111,9 @@ module ActiveRecord if persisted? table = self.class.arel_table - predicate = table[self.class.primary_key].eq(id) - predicate = predicate.and(table[self.class.locking_column].eq(send(self.class.locking_column).to_i)) + lock_col = self.class.locking_column + predicate = table[self.class.primary_key].eq(id). + and(table[lock_col].eq(send(lock_col).to_i)) affected_rows = self.class.unscoped.where(predicate).delete_all |