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 377f2a44c5a01232e196e11203d24dfd5df6c9dc..bf8c546d2e45f361063af4704ffb3a931fdbab4d 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb @@ -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, diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index fa28bc64dfc5721f2b4db0b16d932a25304557c4..8c0bf6396a31f7fd9baaf600077a84f7908bc997 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -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) diff --git a/activerecord/test/cases/pooled_connections_test.rb b/activerecord/test/cases/pooled_connections_test.rb index 2529a33dab2670eb1dbd2119554cda06092c88f0..4e54079ba59110488058267e85840a4a2af7fa26 100644 --- a/activerecord/test/cases/pooled_connections_test.rb +++ b/activerecord/test/cases/pooled_connections_test.rb @@ -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