From 51c9b666e634e2d9551410cbc393bfd83bba7856 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Wed, 14 Jul 2010 15:10:45 -0700 Subject: PostgreSQLAdapter#query bail early if there is no column and dry up our conditionals --- .../active_record/connection_adapters/postgresql_adapter.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index e9443fc237..cf0dc64d2b 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -311,14 +311,16 @@ module ActiveRecord # Quotes PostgreSQL-specific data types for SQL input. def quote(value, column = nil) #:nodoc: - if value.kind_of?(String) && column && column.type == :binary + return super unless column + + if value.kind_of?(String) && column.type == :binary "'#{escape_bytea(value)}'" - elsif value.kind_of?(String) && column && column.sql_type == 'xml' + elsif value.kind_of?(String) && column.sql_type == 'xml' "xml '#{quote_string(value)}'" - elsif value.kind_of?(Numeric) && column && column.sql_type == 'money' + elsif value.kind_of?(Numeric) && column.sql_type == 'money' # Not truly string input, so doesn't require (or allow) escape string syntax. "'#{value.to_s}'" - elsif value.kind_of?(String) && column && column.sql_type =~ /^bit/ + elsif value.kind_of?(String) && column.sql_type =~ /^bit/ case value when /^[01]*$/ "B'#{value}'" # Bit-string notation -- cgit v1.2.3