aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activerecord/lib/active_record/relation.rb2
-rw-r--r--activerecord/test/cases/locking_test.rb13
2 files changed, 1 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index 4ea0c0f2b4..52d5802ee0 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -61,7 +61,7 @@ module ActiveRecord
def to_a
return @records if loaded?
- @records = if @readonly_value.nil?
+ @records = if @readonly_value.nil? && !@klass.locking_enabled?
eager_loading? ? find_with_associations : @klass.find_by_sql(arel.to_sql, @bind_values)
else
IdentityMap.without do
diff --git a/activerecord/test/cases/locking_test.rb b/activerecord/test/cases/locking_test.rb
index 5ceb19e7c8..4ddcdc010b 100644
--- a/activerecord/test/cases/locking_test.rb
+++ b/activerecord/test/cases/locking_test.rb
@@ -15,11 +15,6 @@ class ReadonlyFirstNamePerson < Person
attr_readonly :first_name
end
-# Becouse of introduction of IdentityMap optimistic locking should only be needed
-# in multithreaded applications, or when more then one software operates on database.
-#
-# I'm using ActiveRecord::IdentityMap.without to prevent Identity map from
-# using one record here.
class OptimisticLockingTest < ActiveRecord::TestCase
fixtures :people, :legacy_things, :references
@@ -28,10 +23,6 @@ class OptimisticLockingTest < ActiveRecord::TestCase
# of a test (see test_increment_counter_*).
self.use_transactional_fixtures = false
- def setup
- ActiveRecord::IdentityMap.enabled = false
- end
-
def test_lock_existing
p1 = Person.find(1)
p2 = Person.find(1)
@@ -224,10 +215,6 @@ class OptimisticLockingTest < ActiveRecord::TestCase
end
end
- def teardown
- ActiveRecord::IdentityMap.enabled = true
- end
-
private
def add_counter_column_to(model, col='test_count')