Permalink
Browse files

Merge pull request #313 from darrenli/connection-type-casting

Cast connection options to correct datatype.
  • Loading branch information...
2 parents 560bed8 + 26d07e6 commit 3385de30c87b3c6a78bc76724b62e23905edd2e6 @brianmario committed Oct 4, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 lib/mysql2/client.rb
View
@@ -23,7 +23,14 @@ def initialize(opts = {})
# Set MySQL connection options (each one is a call to mysql_options())
[:reconnect, :connect_timeout, :local_infile, :read_timeout, :write_timeout].each do |key|
next unless opts.key?(key)
- send(:"#{key}=", opts[key])
+ case key
+ when :reconnect, :local_infile
+ send(:"#{key}=", !!opts[key])
+ when :connect_timeout, :read_timeout, :write_timeout
+ send(:"#{key}=", opts[key].to_i)
+ else
+ send(:"#{key}=", opts[key])
+ end
end
# force the encoding to utf8

0 comments on commit 3385de3

Please sign in to comment.