Is it possible to have an Array of hstore in PostgreSQL

activerecord, postgresql, postgresql-9.1, ruby-on-rails-3

Solution

It's certainly possible to create an array-of-hstore column in Rails 4 with e.g. a column spec like this in the table creation:

t.hstore :properties, :array => true

However, there's an encoding bug in Rails 4.0 that unfortunately renders them unusable; essentially you can read from them and they present correctly as arrays of hashes, but not write.

I've opened an issue (with fix patch) at https://github.com/rails/rails/issues/11135 which hopefully will be incorporated soon.

Problem

I am a complete beginner in PostgreSQL. And I was really amazed by the hstore datatype provided by Postgres. Well, I am using the Rails 3 framework and developing a simple app that uses PostgreSQL. I want to store an array of hashes in a field. For Eg.: ``` authors: [ { name: "abc", email: "abc@example.com" }, { name: "xyz", email: "xyz@example.com" } ] ``` Is this possible in PostgreSQL using Rails 3? If so, can somebody give insights on how? Thanks

Original source

Related problems