diff options
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb index 5359c5b666..cf5c8d288e 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb @@ -18,8 +18,6 @@ module ActiveRecord def quote(value, column = nil) #:nodoc: return super unless column - sql_type = type_to_sql(column.type, column.limit, column.precision, column.scale) - case value when Float if value.infinite? || value.nan? @@ -27,16 +25,6 @@ module ActiveRecord else super end - when String - case sql_type - when /^bit/ - case value - when /\A[01]*\Z/ then "B'#{value}'" # Bit-string notation - when /\A[0-9A-F]*\Z/i then "X'#{value}'" # Hexadecimal notation - end - else - super - end else super end @@ -100,6 +88,12 @@ module ActiveRecord "'#{escape_bytea(value.to_s)}'" when OID::Xml::Data "xml '#{quote_string(value.to_s)}'" + when OID::Bit::Data + if value.binary? + "B'#{value}'" + elsif value.hex? + "X'#{value}'" + end else super end @@ -112,7 +106,7 @@ module ActiveRecord # See http://deveiate.org/code/pg/PGconn.html#method-i-exec_prepared-doc # for more information { value: value.to_s, format: 1 } - when OID::Xml::Data + when OID::Xml::Data, OID::Bit::Data value.to_s else super |