diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-06-08 19:40:50 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-06-08 22:38:30 -0700 |
commit | 9051da90e4da2ab0db16530a7f7568e24a0ccaed (patch) | |
tree | 3720db8b18886bba9af70f3142f7bbb59ac5938f | |
parent | d20035910c186401c1d957462f4ad7894347c398 (diff) | |
download | rails-9051da90e4da2ab0db16530a7f7568e24a0ccaed.tar.gz rails-9051da90e4da2ab0db16530a7f7568e24a0ccaed.tar.bz2 rails-9051da90e4da2ab0db16530a7f7568e24a0ccaed.zip |
Enable autoreconnect if available. Freeze constants.
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 076b7f63c2..93aafaaad1 100755 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -151,8 +151,8 @@ module ActiveRecord # # ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate_booleans = false class MysqlAdapter < AbstractAdapter - @@emulate_booleans = true cattr_accessor :emulate_booleans + self.emulate_booleans = true ADAPTER_NAME = 'MySQL'.freeze @@ -162,7 +162,7 @@ module ActiveRecord "Lost connection to MySQL server during query", "MySQL server has gone away" ] - QUOTED_TRUE, QUOTED_FALSE = '1', '0' + QUOTED_TRUE, QUOTED_FALSE = '1'.freeze, '0'.freeze NATIVE_DATABASE_TYPES = { :primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY".freeze, @@ -488,12 +488,17 @@ module ActiveRecord private def connect + @connection.reconnect = true if @connection.respond_to?(:reconnect=) + encoding = @config[:encoding] if encoding @connection.options(Mysql::SET_CHARSET_NAME, encoding) rescue nil end + @connection.ssl_set(@config[:sslkey], @config[:sslcert], @config[:sslca], @config[:sslcapath], @config[:sslcipher]) if @config[:sslkey] + @connection.real_connect(*@connection_options) + execute("SET NAMES '#{encoding}'") if encoding # By default, MySQL 'where id is null' selects the last inserted id. |