aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb10
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