diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2006-02-26 23:12:01 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2006-02-26 23:12:01 +0000 |
commit | 6bd8e351361a895e7ada7d7702bb099034103d62 (patch) | |
tree | 4d41455b0371146a45741dcbf10b76f0912f82c1 /activerecord/lib/active_record/connection_adapters/abstract | |
parent | 3848634a4b2be4ce911a6a7167119a627cb36327 (diff) | |
download | rails-6bd8e351361a895e7ada7d7702bb099034103d62.tar.gz rails-6bd8e351361a895e7ada7d7702bb099034103d62.tar.bz2 rails-6bd8e351361a895e7ada7d7702bb099034103d62.zip |
ActiveRecord::Base.remove_connection explicitly closes database connections and doesn't corrupt the connection cache. Introducing the disconnect! instance method for the PostgreSQL, MySQL, and SQL Server adapters; implementations for the others are welcome. References #3591.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3674 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb index 84dde1b14f..a73ce02104 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb @@ -130,12 +130,13 @@ module ActiveRecord # can be used as argument for establish_connection, for easy # re-establishing of the connection. def self.remove_connection(klass=self) - conn = @@defined_connections[klass.name] - @@defined_connections.delete(klass.name) - @@connection_cache[Thread.current.object_id].delete(klass.name) - active_connections.delete(klass.name) - @connection = nil - conn.config if conn + spec = @@defined_connections[klass.name] + konn = active_connections[klass.name] + @@defined_connections.delete_if { |key, value| value == spec } + @@connection_cache[Thread.current.object_id].delete_if { |key, value| value == konn } + active_connections.delete_if { |key, value| value == konn } + konn.disconnect! if konn + spec.config if spec end # Set the connection for the class. |