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

Changeset 7071

Show
Ignore:
Timestamp:
06/20/07 18:30:35 (1 year ago)
Author:
bitsweat
Message:

MySQL: fix show_variable. Closes #8448.

Files:

Legend:

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

    r6995 r7071  
    11*SVN* 
     2 
     3* MySQL: fix show_variable.  #8448 [matt, Jeremy Kemper] 
    24 
    35* Fixtures: correctly delete and insert fixtures in a single transaction.  #8553 [Michael Schuerig] 
  • trunk/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb

    r6889 r7071  
    410410      # SHOW VARIABLES LIKE 'name' 
    411411      def show_variable(name) 
    412         select_value "SHOW VARIABLES LIKE '#{name}'" 
     412        variables = select_all("SHOW VARIABLES LIKE '#{name}'") 
     413        variables.first['Value'] unless variables.empty? 
    413414      end 
    414415 
  • trunk/activerecord/test/adapter_test.rb

    r6848 r7071  
    4949  if current_adapter?(:MysqlAdapter) 
    5050    def test_charset 
    51       assert @connection.charset 
     51      assert_not_nil @connection.charset 
     52      assert_not_equal 'character_set_database', @connection.charset 
     53      assert_equal @connection.show_variable('character_set_database'), @connection.charset 
    5254    end 
    5355 
    5456    def test_collation 
    55       assert @connection.collation 
     57      assert_not_nil @connection.collation 
     58      assert_not_equal 'collation_database', @connection.collation 
     59      assert_equal @connection.show_variable('collation_database'), @connection.collation 
     60    end 
     61 
     62    def test_show_nonexistent_variable_returns_nil 
     63      assert_nil @connection.show_variable('foo_bar_baz') 
    5664    end 
    5765  end