h2o...@gmail.com
unread,Jun 26, 2013, 2:28:51 PM6/26/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubyonra...@googlegroups.com
Hi,
I have field in postgres (9.2.4) with type json. The field looks like
Column | Type | Modifiers | Storage | Stats target | Description
---------------------+-----------------------------+-----------+----------+--------------+-------------
my_id_field | json | | extended | |
When I do " select my_id_field::json from table1", it returns something like
[]
[]
[]
["abc"]
[]
[]
[]
I like to change this from type json to text[] and included the following in the migration
execute "alter table table1 add column new_id_field text[] default '{}'::text[]"
execute "UPDATE table1 SET new_id_field = [my_id_field] where my_id_field is not null"
I ended up with data like [["abc"]] and [[]], which was not what I wanted
Questions:
1) how do I convert the json type to text[]?
2) in ActiveRecord, how do I select rows from table1 that are not []?
TIA
m