aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2011-12-20 11:18:36 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2011-12-20 14:04:50 -0600
commit96838b5192e46caecc73cf45968fd27b78a41404 (patch)
tree7314876d8b11f739809114be0d961e03b50c9da0 /activerecord/lib/active_record
parent135b3a0dde2edd013b666ab54d35b8b99220f0aa (diff)
downloadrails-96838b5192e46caecc73cf45968fd27b78a41404.tar.gz
rails-96838b5192e46caecc73cf45968fd27b78a41404.tar.bz2
rails-96838b5192e46caecc73cf45968fd27b78a41404.zip
can create hstore records via AR API
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb14
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: