Skip to content

Commit 44dfaee

Browse files
committed
Force a binary encoding on values coming in and out of those columns for ruby 1.9. Fixes ticket #33.
1 parent 2925af5 commit 44dfaee

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11

22
MASTER
33

4+
* Force a binary encoding on values coming in and out of those columns for ruby 1.9.
5+
Fixes ticket #33 [Jeroen Zwartepoorte]
6+
47
* Using change_column will leave default if the type does not change or a new default
58
is not included. Fixes issue #22. [Ransom Briggs]
69

lib/active_record/connection_adapters/sqlserver_adapter.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ def string_to_utf8_encoding(value)
5454
end
5555

5656
def string_to_binary(value)
57+
value = value.dup.force_encoding(Encoding::BINARY) if value.respond_to?(:force_encoding)
5758
"0x#{value.unpack("H*")[0]}"
5859
end
5960

6061
def binary_to_string(value)
62+
value = value.dup.force_encoding(Encoding::BINARY) if value.respond_to?(:force_encoding)
6163
value =~ /[^[:xdigit:]]/ ? value : [value].pack('H*')
6264
end
6365

0 commit comments

Comments
 (0)