Skip to content

Commit bd2425b

Browse files
committed
Merge pull request #333 from sodabrew/revert_pull_330
Revert "move magic values to default query options"
2 parents 235f7ba + a97af45 commit bd2425b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

lib/mysql2/client.rb

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@ class Client
1010
:application_timezone => nil, # timezone Mysql2 will convert to before handing the object back to the caller
1111
:cache_rows => true, # tells Mysql2 to use it's internal row cache for results
1212
:connect_flags => REMEMBER_OPTIONS | LONG_PASSWORD | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION,
13-
:cast => true,
14-
:encoding => 'utf8',
15-
:host => 'localhost',
16-
:port => 3306
13+
:cast => true
1714
}
1815

1916
def initialize(opts = {})
@@ -36,7 +33,8 @@ def initialize(opts = {})
3633
end
3734
end
3835

39-
self.charset_name = opts[:encoding]
36+
# force the encoding to utf8
37+
self.charset_name = opts[:encoding] || 'utf8'
4038

4139
ssl_set(*opts.values_at(:sslkey, :sslcert, :sslca, :sslcapath, :sslcipher))
4240

@@ -49,8 +47,8 @@ def initialize(opts = {})
4947

5048
user = opts[:username] || opts[:user]
5149
pass = opts[:password] || opts[:pass]
52-
host = opts[:host] || opts[:hostname]
53-
port = opts[:port]
50+
host = opts[:host] || opts[:hostname] || 'localhost'
51+
port = opts[:port] || 3306
5452
database = opts[:database] || opts[:dbname] || opts[:db]
5553
socket = opts[:socket] || opts[:sock]
5654
flags = opts[:flags] ? opts[:flags] | @query_options[:connect_flags] : @query_options[:connect_flags]

0 commit comments

Comments
 (0)