Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3246

Show
Ignore:
Timestamp:
12/08/05 05:07:45 (3 years ago)
Author:
bitsweat
Message:

MySQL: more robust test for nullified result hashes. References #3124.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activerecord/CHANGELOG

    r3244 r3246  
    11*SVN* 
     2 
     3* MySQL: more robust test for nullified result hashes.  #3124 [Stefan Kaes] 
    24 
    35* SQLite: find database file when RAILS_ROOT is a symlink.  #3116 [anna@wota.jp] 
  • trunk/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

    r3216 r3246  
    99        begin 
    1010          require_library_or_gem 'mysql' 
    11           # The C version of mysql returns null fields in each_hash if Mysql::VERSION is defined 
    12           ConnectionAdapters::MysqlAdapter.null_values_in_each_hash = Mysql.const_defined?(:VERSION) 
    1311        rescue LoadError => cannot_require_mysql 
    1412          # Only use the supplied backup Ruby/MySQL driver if no driver is already in place 
    1513          begin 
    1614            require 'active_record/vendor/mysql' 
    17             # The ruby version of mysql returns null fields in each_hash 
    18             ConnectionAdapters::MysqlAdapter.null_values_in_each_hash = true 
    1915          rescue LoadError 
    2016            raise cannot_require_mysql 
     
    7874      cattr_accessor :emulate_booleans 
    7975 
    80       cattr_accessor :null_values_in_each_hash 
    81       @@null_values_in_each_hash = false 
    82  
    8376      LOST_CONNECTION_ERROR_MESSAGES = [ 
    8477        "Server shutdown in progress", 
     
    9184        super(connection, logger) 
    9285        @connection_options = connection_options 
     86        @null_values_in_each_hash = Mysql.const_defined?(:VERSION) 
    9387        @config = config 
    9488        connect 
     
    333327          result = execute(sql, name) 
    334328          rows = [] 
    335           if @@null_values_in_each_hash 
     329          if @null_values_in_each_hash 
    336330            result.each_hash { |row| rows << row } 
    337331          else