提交 cccb9988 编写于 作者: J José Valim

Expose connections available in the connection pool.

上级 d382e93d
......@@ -56,7 +56,7 @@ module ConnectionAdapters
# * +wait_timeout+: number of seconds to block and wait for a connection
# before giving up and raising a timeout error (default 5 seconds).
class ConnectionPool
attr_reader :spec
attr_reader :spec, :connections
# Creates a new ConnectionPool object. +spec+ is a ConnectionSpecification
# object which describes database connection information (e.g. adapter,
......
......@@ -579,6 +579,8 @@ def limited_update_conditions(where_sql, quoted_table_name, quoted_primary_key)
protected
def translate_exception(exception, message)
return super unless exception.respond_to?(:errno)
case exception.errno
when 1062
RecordNotUnique.new(message, exception)
......
......@@ -61,12 +61,14 @@ def test_pooled_connection_checkin_one
checkout_checkin_connections 1, 2
assert_equal 2, @connection_count
assert_equal 0, @timed_out
assert_equal 1, ActiveRecord::Base.connection_pool.connections.size
end
def test_pooled_connection_checkin_two
checkout_checkin_connections 2, 3
assert_equal 3, @connection_count
assert_equal 0, @timed_out
assert_equal 1, ActiveRecord::Base.connection_pool.connections.size
end
def test_pooled_connection_checkout_existing_first
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册