diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2016-03-05 12:30:11 +0900 |
---|---|---|
committer | Ryuta Kamizono <kamipo@gmail.com> | 2016-03-06 08:47:49 +0900 |
commit | 6918c18abcadc008e6bb1205958a6123f389b7ce (patch) | |
tree | f107e3091be30e02f89cccfbaf1685af2d12b523 /activerecord | |
parent | 403c57aec052d60431dbae57eedae471d548dd01 (diff) | |
download | rails-6918c18abcadc008e6bb1205958a6123f389b7ce.tar.gz rails-6918c18abcadc008e6bb1205958a6123f389b7ce.tar.bz2 rails-6918c18abcadc008e6bb1205958a6123f389b7ce.zip |
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'
```
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 3 |
1 files changed, 1 insertions, 2 deletions
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 |