public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Default connection allow_concurrency to false (for PostgreSQL)

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Nick Sieger (author)
Thu Sep 04 06:16:29 -0700 2008
jeremy (committer)
Thu Sep 04 06:44:05 -0700 2008
commit  a3f12f575d4bf216a15188ecab2d26a11162bc3b
tree    8a6fe7a68109db3c222abf9c8186e87a437a8f60
parent  2c62baf4bf221aa8aa67f4625fe7011d40c44e82
...
164
165
166
167
168
 
169
170
171
...
164
165
166
 
 
167
168
169
170
0
@@ -164,8 +164,7 @@ module ActiveRecord
0
 
0
       private
0
       def new_connection
0
-        config = spec.config.reverse_merge(:allow_concurrency => true)
0
-        ActiveRecord::Base.send(spec.adapter_method, config)
0
+        ActiveRecord::Base.send(spec.adapter_method, spec.config)
0
       end
0
 
0
       def current_connection_id #:nodoc:
...
43
44
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
47
...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
0
@@ -43,5 +43,20 @@ module ActiveRecord
0
     def assert_no_queries(&block)
0
       assert_queries(0, &block)
0
     end
0
+
0
+    def self.use_concurrent_connections
0
+      setup :connection_allow_concurrency_setup
0
+      teardown :connection_allow_concurrency_teardown
0
+    end
0
+
0
+    def connection_allow_concurrency_setup
0
+      @connection = ActiveRecord::Base.remove_connection
0
+      ActiveRecord::Base.establish_connection(@connection.merge({:allow_concurrency => true}))
0
+    end
0
+
0
+    def connection_allow_concurrency_teardown
0
+      ActiveRecord::Base.clear_all_connections!
0
+      ActiveRecord::Base.establish_connection(@connection)
0
+    end
0
   end
0
 end
...
257
258
259
 
 
260
261
262
...
257
258
259
260
261
262
263
264
0
@@ -257,6 +257,8 @@ unless current_adapter?(:SQLServerAdapter, :SybaseAdapter, :OpenBaseAdapter)
0
     end
0
 
0
     if current_adapter?(:PostgreSQLAdapter, :OracleAdapter)
0
+      use_concurrent_connections
0
+
0
       def test_no_locks_no_wait
0
         first, second = duel { Person.find 1 }
0
         assert first.end > second.end
...
284
285
286
 
 
287
288
289
...
284
285
286
287
288
289
290
291
0
@@ -284,6 +284,8 @@ end
0
 
0
 if current_adapter?(:PostgreSQLAdapter)
0
   class ConcurrentTransactionTest < TransactionTest
0
+    use_concurrent_connections
0
+
0
     # This will cause transactions to overlap and fail unless they are performed on
0
     # separate database connections.
0
     def test_transaction_per_thread

Comments