Skip to content
Browse files

MySQL: fix show_variable. Closes #8448.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7071 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent e963354 commit eb2e30ef249051713d8122a784d8fbfa378e7ae1 @jeremy jeremy committed Jun 20, 2007
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* MySQL: fix show_variable. #8448 [matt, Jeremy Kemper]
+
* Fixtures: correctly delete and insert fixtures in a single transaction. #8553 [Michael Schuerig]
* Fixtures: people(:technomancy, :josh) returns both fixtures. #7880 [technomancy, Josh Peek]
View
3 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -409,7 +409,8 @@ def rename_column(table_name, column_name, new_column_name) #:nodoc:
# SHOW VARIABLES LIKE 'name'
def show_variable(name)
- select_value "SHOW VARIABLES LIKE '#{name}'"
+ variables = select_all("SHOW VARIABLES LIKE '#{name}'")
+ variables.first['Value'] unless variables.empty?
end
private
View
12 activerecord/test/adapter_test.rb
@@ -48,11 +48,19 @@ def test_current_database
if current_adapter?(:MysqlAdapter)
def test_charset
- assert @connection.charset
+ assert_not_nil @connection.charset
+ assert_not_equal 'character_set_database', @connection.charset
+ assert_equal @connection.show_variable('character_set_database'), @connection.charset
end
def test_collation
- assert @connection.collation
+ assert_not_nil @connection.collation
+ assert_not_equal 'collation_database', @connection.collation
+ assert_equal @connection.show_variable('collation_database'), @connection.collation
+ end
+
+ def test_show_nonexistent_variable_returns_nil
+ assert_nil @connection.show_variable('foo_bar_baz')
end
end

0 comments on commit eb2e30e

Please sign in to comment.
Something went wrong with that request. Please try again.