Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix code typo in `MysqlAdapter` .Closes #12647.

  • Loading branch information...
commit d0ea5c5b20687520740bad636951973a34ac2e68 1 parent bbb32d2
Yves Senn senny authored
6 activerecord/CHANGELOG.md
View
@@ -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*
2  activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
View
@@ -559,7 +559,7 @@ def version
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
15 activerecord/test/cases/base_test.rb
View
@@ -604,10 +604,25 @@ def test_readonly_attributes
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
Please sign in to comment.
Something went wrong with that request. Please try again.