提交 6918c18a 编写于 作者: R Ryuta Kamizono

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'
```
上级 403c57ae
......@@ -585,8 +585,7 @@ def type_to_sql(type, limit = nil, precision = nil, scale = nil, unsigned = nil)
# 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册