diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-14 15:10:45 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-07-14 15:10:45 -0700 |
commit | 51c9b666e634e2d9551410cbc393bfd83bba7856 (patch) | |
tree | 496fdd0831503ee7be00d01ae92ef08430bc4ad7 | |
parent | 36150c902b3253101aaa2e14ed31d8d8b9a2e0d2 (diff) | |
download | rails-51c9b666e634e2d9551410cbc393bfd83bba7856.tar.gz rails-51c9b666e634e2d9551410cbc393bfd83bba7856.tar.bz2 rails-51c9b666e634e2d9551410cbc393bfd83bba7856.zip |
PostgreSQLAdapter#query bail early if there is no column and dry up our conditionals
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 10 |
1 files changed, 6 insertions, 4 deletions
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 |