Created
February 7, 2009 03:27
-
-
Save tmm1/59751 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/lib/sequel_core/adapters/mysql.rb b/lib/sequel_core/adapters/mysql.rb | |
| index 89684cf..e7fdd77 100644 | |
| --- a/lib/sequel_core/adapters/mysql.rb | |
| +++ b/lib/sequel_core/adapters/mysql.rb | |
| @@ -58,6 +58,10 @@ module Sequel | |
| opts = server_opts(server) | |
| conn = Mysql.init | |
| conn.options(Mysql::OPT_LOCAL_INFILE, "client") | |
| + if encoding = opts[:encoding] || opts[:charset] | |
| + # set charset _before_ the connect. using an option instead of "SET (NAMES|CHARACTER_SET_*)" works across reconnects | |
| + conn.options(Mysql::SET_CHARSET_NAME, encoding) | |
| + end | |
| conn.real_connect( | |
| opts[:host] || 'localhost', | |
| opts[:user], | |
| @@ -69,14 +73,15 @@ module Sequel | |
| Mysql::CLIENT_MULTI_STATEMENTS + | |
| Mysql::CLIENT_COMPRESS | |
| ) | |
| + | |
| + # increase timeout so mysql server doesn't disconnect us | |
| + conn.query("set @@wait_timeout = #{opts[:timeout] || 2592000}") | |
| + | |
| + # By default, MySQL 'where id is null' selects the last inserted id | |
| + # Turn this off. http://dev.rubyonrails.org/ticket/6778 | |
| + conn.query("set SQL_AUTO_IS_NULL=0") | |
| + | |
| conn.query_with_result = false | |
| - if encoding = opts[:encoding] || opts[:charset] | |
| - conn.query("set character_set_connection = '#{encoding}'") | |
| - conn.query("set character_set_client = '#{encoding}'") | |
| - conn.query("set character_set_database = '#{encoding}'") | |
| - conn.query("set character_set_server = '#{encoding}'") | |
| - conn.query("set character_set_results = '#{encoding}'") | |
| - end | |
| conn.meta_eval{attr_accessor :prepared_statements} | |
| conn.prepared_statements = {} | |
| conn.reconnect = true | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment