Skip to content

Commit 9d38e75

Browse files
committed
First pass at separating out connect options from query options
1 parent 5e21bf2 commit 9d38e75

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/mysql2/client.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
module Mysql2
22
class Client
33
attr_reader :query_options, :read_timeout
4+
@@default_connect_options = {
5+
:connect_flags => REMEMBER_OPTIONS | LONG_PASSWORD | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION,
6+
:default_file => nil,
7+
:default_group => nil
8+
}
9+
410
@@default_query_options = {
511
:as => :hash, # the type of object you want each row back as; also supports :array (an array of values)
612
:async => false, # don't wait for a result after sending the query, you'll have to monitor the socket yourself then eventually call Mysql2::Client#async_result
@@ -9,16 +15,14 @@ class Client
915
:database_timezone => :local, # timezone Mysql2 will assume datetime objects are stored in
1016
:application_timezone => nil, # timezone Mysql2 will convert to before handing the object back to the caller
1117
:cache_rows => true, # tells Mysql2 to use it's internal row cache for results
12-
:connect_flags => REMEMBER_OPTIONS | LONG_PASSWORD | LONG_FLAG | TRANSACTIONS | PROTOCOL_41 | SECURE_CONNECTION,
13-
:cast => true,
14-
:default_file => nil,
15-
:default_group => nil
18+
:cast => true
1619
}
1720

1821
def initialize(opts = {})
1922
opts = Mysql2::Util.key_hash_as_symbols( opts )
2023
@read_timeout = nil
2124
@query_options = @@default_query_options.dup
25+
@query_options.merge! @@default_connect_options
2226
@query_options.merge! opts
2327

2428
initialize_ext

0 commit comments

Comments
 (0)