Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Only string_to_binary if the column responds

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4040 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 91ea35307a1ce21d56a147c42ecf6c9061582c67 1 parent a5991d8
@dhh dhh authored
View
2  activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -116,7 +116,7 @@ def native_database_types #:nodoc
# 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
2  activerecord/lib/active_record/connection_adapters/oracle_adapter.rb
@@ -210,7 +210,7 @@ def quote_string(string) #:nodoc:
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
2  activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb
@@ -330,7 +330,7 @@ def rollback_db_transaction
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
2  activerecord/lib/active_record/connection_adapters/sybase_adapter.rb
@@ -263,7 +263,7 @@ def quoted_false
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

0 comments on commit 91ea353

Please sign in to comment.
Something went wrong with that request. Please try again.