diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index c26b61443b..6e169ae5c5 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -50,11 +50,15 @@ module ActiveRecord end end - def cast_hstore(string) - kvs = string.split(', ').map { |kv| - kv.split('=>').map { |k| k[1...-1] } - } - Hash[kvs] + def cast_hstore(object) + if Hash === object + object.map { |k,v| "#{k}=>#{v}" }.join ', ' + else + kvs = object.split(', ').map { |kv| + kv.split('=>').map { |k| k[1...-1] } + } + Hash[kvs] + end end end # :startdoc: |