From 832eb2d24704f92e26e944bb4db38afe56a93c89 Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Fri, 15 Oct 2010 07:45:07 -0700 Subject: [PATCH] add option for setting the wait_timeout in the AR adapter (this can be done in database.yml) --- lib/active_record/connection_adapters/mysql2_adapter.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/active_record/connection_adapters/mysql2_adapter.rb b/lib/active_record/connection_adapters/mysql2_adapter.rb index 78a7901..a442fa8 100644 --- a/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -617,8 +617,13 @@ module ActiveRecord # Turn this off. http://dev.rubyonrails.org/ticket/6778 variable_assignments = ['SQL_AUTO_IS_NULL=0'] encoding = @config[:encoding] + + # make sure we set the encoding variable_assignments << "NAMES '#{encoding}'" if encoding + # increase timeout so mysql server doesn't disconnect us + variable_assignments << "@@wait_timeout = #{@config[:wait_timeout] || 2592000}" + execute("SET #{variable_assignments.join(', ')}", :skip_logging) end