Skip to content

Commit

Permalink
fix code typo in MysqlAdapter .Closes #12647.
Browse files Browse the repository at this point in the history
Conflicts:
	activerecord/CHANGELOG.md
  • Loading branch information
senny committed Oct 30, 2013
1 parent dece340 commit 5d7e865
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions activerecord/test/cases/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -607,10 +607,25 @@ def test_attr_readonly_is_class_level_setting
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
Expand Down

0 comments on commit 5d7e865

Please sign in to comment.