diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-17 13:42:42 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-02-17 13:42:42 -0800 |
commit | 23ce2f61b5a7699af8213bf1b5d581da194ab8f4 (patch) | |
tree | b2adcb398f6b5171e15fd681fd23d5c94ca1cdcf /activerecord/lib/active_record/connection_adapters/postgresql/cast.rb | |
parent | fe42effb11a97cf19777d7b0dba7e1e2dfd3316c (diff) | |
parent | c18e7ab44706735d9b1274760bdc62ad5bef7757 (diff) | |
download | rails-23ce2f61b5a7699af8213bf1b5d581da194ab8f4.tar.gz rails-23ce2f61b5a7699af8213bf1b5d581da194ab8f4.tar.bz2 rails-23ce2f61b5a7699af8213bf1b5d581da194ab8f4.zip |
Merge branch 'master' into adequaterecord
* master:
Revert "Merge pull request #13344 from ccutrer/fix-from-default-select"
No need to use symbols
Don't skip tests if they are not broken. Just don't define they
Fix typo [ci skip]
Resolve encoding issues with arrays of hstore (bug 11135).
Fix coffeescript sample [ci skip]
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/cast.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql/cast.rb | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb index 35ce881302..3a3b500b1f 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/cast.rb @@ -35,11 +35,11 @@ module ActiveRecord end end - def hstore_to_string(object) + def hstore_to_string(object, array_member = false) if Hash === object - object.map { |k,v| - "#{escape_hstore(k)}=>#{escape_hstore(v)}" - }.join ',' + string = object.map { |k, v| "#{escape_hstore(k)}=>#{escape_hstore(v)}" }.join(',') + string = escape_hstore(string) if array_member + string else object end @@ -49,10 +49,10 @@ module ActiveRecord if string.nil? nil elsif String === string - Hash[string.scan(HstorePair).map { |k,v| + Hash[string.scan(HstorePair).map { |k, v| v = v.upcase == 'NULL' ? nil : v.gsub(/\A"(.*)"\Z/m,'\1').gsub(/\\(.)/, '\1') k = k.gsub(/\A"(.*)"\Z/m,'\1').gsub(/\\(.)/, '\1') - [k,v] + [k, v] }] else string |