Skip to content

Commit ddb1c6e

Browse files
committed
Per tests from BanzaiMan, convert non-nil values before passing them to the C connect function.
1 parent 890c539 commit ddb1c6e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/mysql2/client.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ def initialize(opts = {})
5656
socket = opts[:socket] || opts[:sock]
5757
flags = opts[:flags] ? opts[:flags] | @query_options[:connect_flags] : @query_options[:connect_flags]
5858

59+
# Correct the data types before passing these values down to the C level
60+
user = user.to_s unless user.nil?
61+
pass = pass.to_s unless pass.nil?
62+
host = host.to_s unless host.nil?
63+
port = port.to_i unless port.nil?
64+
database = database.to_s unless database.nil?
65+
socket = socket.to_s unless socket.nil?
66+
5967
connect user, pass, host, port, database, socket, flags
6068
end
6169

0 commit comments

Comments
 (0)