Skip to content

Commit cd089e9

Browse files
committed
use '?' for replacement character even on 2.1 and mysql 5.1
1 parent 26f66c3 commit cd089e9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/mysql2/error.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module Mysql2
44
class Error < StandardError
55
REPLACEMENT_CHAR = '?'
6-
ENCODE_OPTS = {:undef => :replace, :invalid => :replace}
6+
ENCODE_OPTS = {:undef => :replace, :invalid => :replace, :replace => REPLACEMENT_CHAR}
77

88
attr_accessor :error_number, :sql_state
99
attr_writer :server_version
@@ -60,7 +60,7 @@ def clean_message(message)
6060
message.encode(ENCODE_OPTS)
6161
else
6262
if message.respond_to? :scrub
63-
message.scrub.encode(ENCODE_OPTS)
63+
message.scrub(REPLACEMENT_CHAR).encode(ENCODE_OPTS)
6464
else
6565
# This is ugly as hell but Ruby 1.9 doesn't provide a way to clean a string
6666
# and retain it's valid UTF-8 characters, that I know of.

0 commit comments

Comments
 (0)