diff options
author | Yves Senn <yves.senn@gmail.com> | 2013-10-28 10:02:35 +0100 |
---|---|---|
committer | Yves Senn <yves.senn@gmail.com> | 2013-10-30 18:12:26 +0100 |
commit | d0ea5c5b20687520740bad636951973a34ac2e68 (patch) | |
tree | 88d7f80e9831c0177b7ea7a2474ef0b7b70df9ba /activerecord | |
parent | bbb32d205f2391be21d40ad64b693a4c0d9aa534 (diff) | |
download | rails-d0ea5c5b20687520740bad636951973a34ac2e68.tar.gz rails-d0ea5c5b20687520740bad636951973a34ac2e68.tar.bz2 rails-d0ea5c5b20687520740bad636951973a34ac2e68.zip |
fix code typo in `MysqlAdapter` .Closes #12647.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG.md | 6 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/mysql_adapter.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/base_test.rb | 15 |
3 files changed, 22 insertions, 1 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md index ff8e0beb04..08bab91504 100644 --- a/activerecord/CHANGELOG.md +++ b/activerecord/CHANGELOG.md @@ -1,3 +1,9 @@ +* Fix code typo in `MysqlAdapter` when `Encoding.default_internal` is set. + + Fixes #12647. + + *Yves Senn* + * ActiveRecord::Base#attribute_for_inspect now truncates long arrays (more than 10 elements) *Jan Bernacki* diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 41a47183e0..88c9494fc6 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -559,7 +559,7 @@ module ActiveRecord def set_field_encoding field_name field_name.force_encoding(client_encoding) if internal_enc = Encoding.default_internal - field_name = field_name.encoding(internal_enc) + field_name = field_name.encode!(internal_enc) end field_name end diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb index 4de92b71be..82b20e8cee 100644 --- a/activerecord/test/cases/base_test.rb +++ b/activerecord/test/cases/base_test.rb @@ -604,10 +604,25 @@ class BasicsTest < ActiveRecord::TestCase end def test_unicode_column_name + Weird.reset_column_information weird = Weird.create(:なまえ => 'たこ焼き仮面') assert_equal 'たこ焼き仮面', weird.なまえ end + def test_respect_internal_encoding + if current_adapter?(:PostgreSQLAdapter) + skip 'pg does not respect internal encoding and always returns utf8' + end + old_default_internal = Encoding.default_internal + silence_warnings { Encoding.default_internal = "EUC-JP" } + + Weird.reset_column_information + + assert_equal ["EUC-JP"], Weird.columns.map {|c| c.name.encoding.name }.uniq + ensure + silence_warnings { Encoding.default_internal = old_default_internal } + end + def test_non_valid_identifier_column_name weird = Weird.create('a$b' => 'value') weird.reload |