diff options
author | Nick Sieger <nick@nicksieger.com> | 2008-09-04 15:16:29 +0200 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-09-04 15:44:05 +0200 |
commit | a3f12f575d4bf216a15188ecab2d26a11162bc3b (patch) | |
tree | 8a6fe7a68109db3c222abf9c8186e87a437a8f60 /activerecord/lib | |
parent | 2c62baf4bf221aa8aa67f4625fe7011d40c44e82 (diff) | |
download | rails-a3f12f575d4bf216a15188ecab2d26a11162bc3b.tar.gz rails-a3f12f575d4bf216a15188ecab2d26a11162bc3b.tar.bz2 rails-a3f12f575d4bf216a15188ecab2d26a11162bc3b.zip |
Default connection allow_concurrency to false (for PostgreSQL)
Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb | 3 | ||||
-rw-r--r-- | activerecord/lib/active_record/test_case.rb | 15 |
2 files changed, 16 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb index 6b4bc2574d..5806dea061 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -164,8 +164,7 @@ module ActiveRecord 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: diff --git a/activerecord/lib/active_record/test_case.rb b/activerecord/lib/active_record/test_case.rb index ffaa41282f..eabf06fc3b 100644 --- a/activerecord/lib/active_record/test_case.rb +++ b/activerecord/lib/active_record/test_case.rb @@ -43,5 +43,20 @@ module ActiveRecord 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 |