Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implements ActiveRecord::Base.connection_config to be able to check t…

…he configuration of the current connection at runtime
  • Loading branch information...
commit 3b10b8a201d9fbef831be81d7a4bc9b82c75a6f4 1 parent 28f1c21
@fxn fxn authored
View
3  activerecord/CHANGELOG
@@ -1,5 +1,8 @@
*Rails 3.1.0 (unreleased)*
+* The configuration for the current database connection is now accessible via
+ ActiveRecord::Base.connection_config. [fxn]
+
* limits and offsets are removed from COUNT queries unless both are supplied.
For example:
View
10 activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
@@ -89,6 +89,16 @@ def connection
retrieve_connection
end
+ # Returns the configuration of the associated connection as a hash:
+ #
+ # ActiveRecord::Base.connection_config
+ # # => {:pool=>5, :timeout=>5000, :database=>"db/development.sqlite3", :adapter=>"sqlite3"}
+ #
+ # Please use only for reading.
+ def connection_config
+ connection_pool.spec.config
+ end
+
def connection_pool
connection_handler.retrieve_connection_pool(self)
end
View
5 activerecord/test/cases/pooled_connections_test.rb
@@ -94,6 +94,11 @@ def test_undefined_connection_returns_false
ActiveRecord::Base.connection_handler = old_handler
end
+ def test_connection_config
+ ActiveRecord::Base.establish_connection(@connection)
+ assert_equal @connection, ActiveRecord::Base.connection_config
+ end
+
def test_with_connection_nesting_safety
ActiveRecord::Base.establish_connection(@connection.merge({:pool => 1, :wait_timeout => 0.1}))
Please sign in to comment.
Something went wrong with that request. Please try again.