From 6918c18abcadc008e6bb1205958a6123f389b7ce Mon Sep 17 00:00:00 2001 From: Ryuta Kamizono Date: Sat, 5 Mar 2016 12:30:11 +0900 Subject: Simply use `select_value` in `show_variable` `SELECT @@name` statement returns only single row or `StatementInvalid`. ``` root@localhost [activerecord_unittest] > SELECT @@version; +-----------+ | @@version | +-----------+ | 5.7.9-log | +-----------+ 1 row in set (0.00 sec) root@localhost [activerecord_unittest] > SELECT @@unknown_variable; ERROR 1193 (HY000): Unknown system variable 'missing_variable' ``` --- .../lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index b12bac2737..cc057146c7 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -585,8 +585,7 @@ module ActiveRecord # SHOW VARIABLES LIKE 'name' def show_variable(name) - variables = select_all("select @@#{name} as 'Value'", 'SCHEMA') - variables.first['Value'] unless variables.empty? + select_value("SELECT @@#{name}", 'SCHEMA') rescue ActiveRecord::StatementInvalid nil end -- cgit v1.2.3