Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

PostgreSQLAdapter#query bail early if there is no column and dry up o…

…ur conditionals
  • Loading branch information...
commit 51c9b666e634e2d9551410cbc393bfd83bba7856 1 parent 36150c9
@tenderlove tenderlove authored
View
10 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -311,14 +311,16 @@ def unescape_bytea(value)
# 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
Please sign in to comment.
Something went wrong with that request. Please try again.