1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #26559 from kamipo/fix_wait_timeout_as_string

Fix `wait_timeout` to configurable for mysql2 adapter
This commit is contained in:
Rafael França 2017-02-23 16:46:50 -05:00 committed by GitHub
commit 771637269d
3 changed files with 25 additions and 2 deletions

View file

@ -1,3 +1,10 @@
* Fix `wait_timeout` to configurable for mysql2 adapter.
Fixes #26556.
*Ryuta Kamizono*
## Rails 5.1.0.beta1 (February 23, 2017) ##
* Correctly dump native timestamp types for MySQL.

View file

@ -870,9 +870,9 @@ module ActiveRecord
variables["sql_auto_is_null"] = 0
# Increase timeout so the server doesn't disconnect us.
wait_timeout = @config[:wait_timeout]
wait_timeout = self.class.type_cast_config_to_integer(@config[:wait_timeout])
wait_timeout = 2147483 unless wait_timeout.is_a?(Integer)
variables["wait_timeout"] = self.class.type_cast_config_to_integer(wait_timeout)
variables["wait_timeout"] = wait_timeout
defaults = [":default", :default].to_set

View file

@ -85,6 +85,22 @@ class Mysql2ConnectionTest < ActiveRecord::Mysql2TestCase
assert_equal false, @connection.active?
end
def test_wait_timeout_as_string
run_without_connection do |orig_connection|
ActiveRecord::Base.establish_connection(orig_connection.merge(wait_timeout: "60"))
result = ActiveRecord::Base.connection.select_value("SELECT @@SESSION.wait_timeout")
assert_equal 60, result
end
end
def test_wait_timeout_as_url
run_without_connection do |orig_connection|
ActiveRecord::Base.establish_connection(orig_connection.merge("url" => "mysql2:///?wait_timeout=60"))
result = ActiveRecord::Base.connection.select_value("SELECT @@SESSION.wait_timeout")
assert_equal 60, result
end
end
def test_mysql_connection_collation_is_configured
assert_equal "utf8_unicode_ci", @connection.show_variable("collation_connection")
assert_equal "utf8_general_ci", ARUnit2Model.connection.show_variable("collation_connection")