mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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:
@@ -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
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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)}'"
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user