Only string_to_binary if the column responds

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4040 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
David Heinemeier Hansson
2006-03-26 04:15:57 +00:00
parent a5991d8491
commit 91ea35307a
4 changed files with 4 additions and 4 deletions

View File

@@ -116,7 +116,7 @@ module ActiveRecord
# QUOTING ==================================================
def quote(value, column = nil)
if value.kind_of?(String) && column && column.type == :binary
if value.kind_of?(String) && column && column.type == :binary && column.class.respond_to?(:string_to_binary)
s = column.class.string_to_binary(value).unpack("H*")[0]
"x'#{s}'"
else

View File

@@ -210,7 +210,7 @@ begin
end
def quote(value, column = nil) #:nodoc:
if column and column.type == :binary then %Q{empty_#{ column.sql_type }()}
if column && column.type == :binary then %Q{empty_#{ column.sql_type }()}
else case value
when String then %Q{'#{quote_string(value)}'}
when NilClass then 'null'

View File

@@ -330,7 +330,7 @@ module ActiveRecord
def quote(value, column = nil)
case value
when String
if column && column.type == :binary
if column && column.type == :binary && column.class.respond_to?(:string_to_binary)
"'#{quote_string(column.class.string_to_binary(value))}'"
else
"'#{quote_string(value)}'"

View File

@@ -263,7 +263,7 @@ module ActiveRecord
def quote(value, column = nil)
case value
when String
if column && column.type == :binary
if column && column.type == :binary && column.class.respond_to?(:string_to_binary)
"#{quote_string(column.class.string_to_binary(value))}"
elsif value =~ /^[+-]?[0-9]+$/o
value