I'm using the pg_array extension of Ruby Sequel.
When I select a column that is a Postgresql array, the result is a string in Ruby. How do I get this to be a Ruby array so I can use things like .each on it?
CaseTypeCategory.first(category_name: 'Subscription')[:values]
=> "{value_one,value_two}"
CaseTypeCategory.first(category_name: 'Subscription')[:values][0]
=> "{"
Our database config includes:
Sequel.extension :pg_array, :pg_inet, :pg_json
And the migration to add the columns included this:
alter_table :case_type_categories do
add_column :values, "text[]"
end
I can write raw SQL to access single elements in the array:
select values[1] from case_type_categories where category_name = 'Subscription'