mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Merge pull request #8547 from printercu/patch-1
fix for messages in invalid encoding from db-drivers Conflicts: activerecord/lib/active_record/connection_adapters/abstract_adapter.rb activerecord/test/cases/connection_adapters/abstract_adapter_test.rb
This commit is contained in:
commit
3793b4063a
2 changed files with 14 additions and 1 deletions
|
@ -457,7 +457,12 @@ module ActiveRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def translate_exception_class(e, sql)
|
def translate_exception_class(e, sql)
|
||||||
|
begin
|
||||||
message = "#{e.class.name}: #{e.message}: #{sql}"
|
message = "#{e.class.name}: #{e.message}: #{sql}"
|
||||||
|
rescue Encoding::CompatibilityError
|
||||||
|
message = "#{e.class.name}: #{e.message.force_encoding sql.encoding}: #{sql}"
|
||||||
|
end
|
||||||
|
|
||||||
@logger.error message if @logger
|
@logger.error message if @logger
|
||||||
exception = translate_exception(e, message)
|
exception = translate_exception(e, message)
|
||||||
exception.set_backtrace e.backtrace
|
exception.set_backtrace e.backtrace
|
||||||
|
|
|
@ -213,6 +213,14 @@ module ActiveRecord
|
||||||
test "type_to_sql returns a String for unmapped types" do
|
test "type_to_sql returns a String for unmapped types" do
|
||||||
assert_equal "special_db_type", @connection.type_to_sql(:special_db_type)
|
assert_equal "special_db_type", @connection.type_to_sql(:special_db_type)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_log_invalid_encoding
|
||||||
|
assert_raise ActiveRecord::StatementInvalid do
|
||||||
|
@connection.send :log, "SELECT 'ы' FROM DUAL" do
|
||||||
|
raise 'ы'.force_encoding(Encoding::ASCII_8BIT)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
class AdapterTestWithoutTransaction < ActiveRecord::TestCase
|
class AdapterTestWithoutTransaction < ActiveRecord::TestCase
|
||||||
|
|
Loading…
Reference in a new issue