diff options
author | Sean Griffin <sean@seantheprogrammer.com> | 2015-11-23 15:40:05 -0700 |
---|---|---|
committer | Sean Griffin <sean@seantheprogrammer.com> | 2015-11-23 15:40:05 -0700 |
commit | 9d70526ea9ca45a1e6e98ead682a9bfae98afc9f (patch) | |
tree | 5d5c858410f56617d5acaacd2cf97e6295de0742 /activerecord/lib | |
parent | 1e5c274f59c0fe1764bea6bf778d11d0c0fc0b4f (diff) | |
parent | d5ff01bcb3c88e8790494e6db16532e55e87fbc1 (diff) | |
download | rails-9d70526ea9ca45a1e6e98ead682a9bfae98afc9f.tar.gz rails-9d70526ea9ca45a1e6e98ead682a9bfae98afc9f.tar.bz2 rails-9d70526ea9ca45a1e6e98ead682a9bfae98afc9f.zip |
Merge pull request #22388 from kamipo/set_field_encoding_is_only_needed_for_mysql_adapter
`set_field_encoding` is only needed for `MysqlAdapter`
Diffstat (limited to 'activerecord/lib')
3 files changed, 8 insertions, 9 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 deef246c37..ee40e3a8d2 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -588,10 +588,8 @@ module ActiveRecord sql = "SHOW FULL FIELDS FROM #{quote_table_name(table_name)}" execute_and_free(sql, 'SCHEMA') do |result| each_hash(result).map do |field| - field_name = set_field_encoding(field[:Field]) - sql_type = field[:Type] - type_metadata = fetch_type_metadata(sql_type, field[:Extra]) - new_column(field_name, field[:Default], type_metadata, field[:Null] == "YES", nil, field[:Collation]) + type_metadata = fetch_type_metadata(field[:Type], field[:Extra]) + new_column(field[:Field], field[:Default], type_metadata, field[:Null] == "YES", nil, field[:Collation]) end end end diff --git a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb index 773ecbe126..3944698910 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql2_adapter.rb @@ -185,10 +185,6 @@ module ActiveRecord def full_version @full_version ||= @connection.server_info[:version] end - - def set_field_encoding field_name - field_name - end end end end diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 89d18ee14e..f2d7b54105 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -104,6 +104,11 @@ module ActiveRecord end end + def new_column(field, default, sql_type_metadata = nil, null = true, default_function = nil, collation = nil) # :nodoc: + field = set_field_encoding(field) + super + end + def error_number(exception) # :nodoc: exception.errno if exception.respond_to?(:errno) end @@ -463,7 +468,7 @@ module ActiveRecord @full_version ||= @connection.server_info end - def set_field_encoding field_name + def set_field_encoding(field_name) field_name.force_encoding(client_encoding) if internal_enc = Encoding.default_internal field_name = field_name.encode!(internal_enc) |