Permalink
Browse files

Default connection allow_concurrency to false (for PostgreSQL)

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
1 parent 2c62baf commit a3f12f575d4bf216a15188ecab2d26a11162bc3b @nicksieger nicksieger committed with jeremy Sep 4, 2008
@@ -164,8 +164,7 @@ def checkin(conn)
private
def new_connection
- config = spec.config.reverse_merge(:allow_concurrency => true)
- ActiveRecord::Base.send(spec.adapter_method, config)
+ ActiveRecord::Base.send(spec.adapter_method, spec.config)
end
def current_connection_id #:nodoc:
@@ -43,5 +43,20 @@ def assert_queries(num = 1)
def assert_no_queries(&block)
assert_queries(0, &block)
end
+
+ def self.use_concurrent_connections
+ setup :connection_allow_concurrency_setup
+ teardown :connection_allow_concurrency_teardown
+ end
+
+ def connection_allow_concurrency_setup
+ @connection = ActiveRecord::Base.remove_connection
+ ActiveRecord::Base.establish_connection(@connection.merge({:allow_concurrency => true}))
+ end
+
+ def connection_allow_concurrency_teardown
+ ActiveRecord::Base.clear_all_connections!
+ ActiveRecord::Base.establish_connection(@connection)
+ end
end
end
@@ -257,6 +257,8 @@ def test_sane_lock_method
end
if current_adapter?(:PostgreSQLAdapter, :OracleAdapter)
+ use_concurrent_connections
+
def test_no_locks_no_wait
first, second = duel { Person.find 1 }
assert first.end > second.end
@@ -284,6 +284,8 @@ def remove_exception_raising_after_create_callback_to_topic
if current_adapter?(:PostgreSQLAdapter)
class ConcurrentTransactionTest < TransactionTest
+ use_concurrent_connections
+
# This will cause transactions to overlap and fail unless they are performed on
# separate database connections.
def test_transaction_per_thread

0 comments on commit a3f12f5

Please sign in to comment.