aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/locking
diff options
context:
space:
mode:
authorBen Moss <ben@mossity.com>2013-03-09 14:54:19 -0500
committerBen Moss <ben@mossity.com>2013-03-09 15:16:15 -0500
commit992d87db02507363a4ad4ab40a3e4c4b32cf0408 (patch)
tree9802314e8600e0bd5640538e00fd581c6cdf7e79 /activerecord/lib/active_record/locking
parentca35454b498657cd94cb0a4203801e52687aa9e0 (diff)
downloadrails-992d87db02507363a4ad4ab40a3e4c4b32cf0408.tar.gz
rails-992d87db02507363a4ad4ab40a3e4c4b32cf0408.tar.bz2
rails-992d87db02507363a4ad4ab40a3e4c4b32cf0408.zip
Deprecate #connection in favour of accessing it via the class
This allows end-users to have a `connection` method on their models without clashing with ActiveRecord internals.
Diffstat (limited to 'activerecord/lib/active_record/locking')
-rw-r--r--activerecord/lib/active_record/locking/optimistic.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb
index 701949e57b..209de78898 100644
--- a/activerecord/lib/active_record/locking/optimistic.rb
+++ b/activerecord/lib/active_record/locking/optimistic.rb
@@ -86,7 +86,7 @@ module ActiveRecord
)
).arel.compile_update(arel_attributes_with_values_for_update(attribute_names))
- affected_rows = connection.update stmt
+ affected_rows = self.class.connection.update stmt
unless affected_rows == 1
raise ActiveRecord::StaleObjectError.new(self, "update")
@@ -117,7 +117,7 @@ module ActiveRecord
if locking_enabled?
column_name = self.class.locking_column
column = self.class.columns_hash[column_name]
- substitute = connection.substitute_at(column, relation.bind_values.length)
+ substitute = self.class.connection.substitute_at(column, relation.bind_values.length)
relation = relation.where(self.class.arel_table[column_name].eq(substitute))
relation.bind_values << [column, self[column_name].to_i]