diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index 60fd995..1b9d002 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -2085,7 +2085,7 @@ module ActiveRecord #:nodoc: end def quote_bound_value(value) #:nodoc: - if value.respond_to?(:map) && !value.is_a?(String) + if value.respond_to?(:map) && !value.is_a?(String) && !value.is_a?(ActiveSupport::Multibyte::Chars) if value.respond_to?(:empty?) && value.empty? connection.quote(nil) else diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb index f48b62b..7695358 100644 --- a/activerecord/test/cases/finder_test.rb +++ b/activerecord/test/cases/finder_test.rb @@ -387,6 +387,14 @@ class FinderTest < ActiveRecord::TestCase assert_equal ActiveRecord::Base.connection.quote(''), bind('?', '') end + def test_bind_string_with_nl + assert_equal ActiveRecord::Base.connection.quote("a\nb"), bind('?', "a\nb") + end + + def test_bind_mb_string_with_nl + assert_equal ActiveRecord::Base.connection.quote("a\nb"), bind('?', "a\nb".chars) + end + def test_bind_record o = Struct.new(:quoted_id).new(1) assert_equal '1', bind('?', o)