diff options
author | Yasuo Honda <yasuo.honda@gmail.com> | 2015-08-18 20:02:49 +0000 |
---|---|---|
committer | Yasuo Honda <yasuo.honda@gmail.com> | 2015-08-21 13:00:15 +0000 |
commit | 0fa842487472517a13acffcd2558d592bfbed633 (patch) | |
tree | 5900159812b628c33d2954ae5bea1cb3ba3ac53d /activerecord/lib/active_record | |
parent | 95cb2e3a8a306701d3720fa5e1a9486655aea923 (diff) | |
download | rails-0fa842487472517a13acffcd2558d592bfbed633.tar.gz rails-0fa842487472517a13acffcd2558d592bfbed633.tar.bz2 rails-0fa842487472517a13acffcd2558d592bfbed633.zip |
Support MySQL 5.7.8 which enables show_compatibility_56=off
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 2 |
2 files changed, 7 insertions, 3 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 96ea866580..dff6c69168 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -727,8 +727,12 @@ module ActiveRecord # SHOW VARIABLES LIKE 'name' def show_variable(name) - variables = select_all("SHOW VARIABLES LIKE '#{name}'", 'SCHEMA') - variables.first['Value'] unless variables.empty? + begin + variables = select_all("select @@#{name} as 'Value'", 'SCHEMA') + variables.first['Value'] unless variables.empty? + rescue ActiveRecord::StatementInvalid => _e + nil + end end # Returns a table's primary key and belonging sequence. diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 2ae462d773..0738c59ddf 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -223,7 +223,7 @@ module ActiveRecord return @client_encoding if @client_encoding result = exec_query( - "SHOW VARIABLES WHERE Variable_name = 'character_set_client'", + "select @@character_set_client", 'SCHEMA') @client_encoding = ENCODINGS[result.rows.last.last] end |