Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7953

Show
Ignore:
Timestamp:
10/17/07 13:14:31 (1 year ago)
Author:
lawrence
Message:

SQL Server fix for binary tests. References #7987 [roderickvd]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • adapters/sqlserver/lib/active_record/connection_adapters/sqlserver_adapter.rb

    r7911 r7953  
    123123      # These methods will only allow the adapter to insert binary data with a length of 7K or less 
    124124      # because of a SQL Server statement length policy. 
    125       def self.string_to_binary(value) 
    126         value.gsub(/(\r|\n|\0|\x1a)/) do 
    127           case $1 
    128             when "\r"   then  "%00" 
    129             when "\n"   then  "%01" 
    130             when "\0"   then  "%02" 
    131             when "\x1a" then  "%03" 
    132           end 
    133         end 
    134       end 
    135  
    136       def self.binary_to_string(value) 
    137         value.gsub(/(%00|%01|%02|%03)/) do 
    138           case $1 
    139             when "%00"    then  "\r" 
    140             when "%01"    then  "\n" 
    141             when "%02\0"  then  "\0" 
    142             when "%03"    then  "\x1a" 
    143           end 
    144         end 
    145       end 
     125      def self.string_to_binary(value)  
     126              Base64.encode64(value)  
     127      end  
     128                
     129            def self.binary_to_string(value)  
     130              Base64.decode64(value)  
     131            end  
    146132    end 
    147133