From 0c46dbbc4557acb1e0af1c8ce697305398070922 Mon Sep 17 00:00:00 2001 From: Ryan Fitzgerald Date: Tue, 24 Apr 2012 20:43:10 -0700 Subject: Always quote hstore keys and values escape_hstore uses quotation marks around keys and values only if it seems necessary. However, it currently breaks in the presence of some non-ASCII characters. Instead of trying to guess exactly which characters are safe, it seems better to always use quotes. --- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 10a178e369..8248eb9d0b 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -88,9 +88,8 @@ module ActiveRecord def escape_hstore(value) value.nil? ? 'NULL' - : value =~ /[=\s,>]/ ? '"%s"' % value.gsub(/(["\\])/, '\\\\\1') : value == "" ? '""' - : value.to_s.gsub(/(["\\])/, '\\\\\1') + : '"%s"' % value.gsub(/(["\\])/, '\\\\\1') end end # :startdoc: -- cgit v1.2.3