I have active_record setup to use a Postgresql database. One of the columns is a character varying[] (basically a varchar array).
Anyway, my import routine then reads a tab-delimited text file and inserts records. All is fine until I get to an array. The column that should be converted to an array is comma separated. But the line itself is tab separated.
A sample of the data I’m importing looks like (tab delimited):
Col1 Col2 Col3 Col4
----------------------------------------------
Apple Pear Sweet,Round,Green Fruit
Col3 is imported like (ruby): col3.split(/,/) which gives me an array in Ruby. But active_record bombs out with:
PG::Error: ERROR: array value must start with “{” or dimension information (ActiveRecord::StatementInvalid)
How can I insert that column correctly?
Also, sometimes, col3 will be NULL.
I was able to insert using the following Ruby code: