Closed edkurowski closed 10 years ago
:+1:
Will this properly create the schema as an array type? I'd love to take a patch to do this, but I think we'll need some way to denote in the collection map that the column should be an array type, so that we can create the right schema. That'd also let us preserve compatibility with existing installations, by defaulting to JSON unless the schema calls out an array type.
I'd also like to see some tests.
This does create the proper array type in postgres and will insert the data correctly. I'll update the logic so that it will only treat the value as an array type if the schema has been set up to match. And of course, I will have some tests for you. Thanks.
Thanks! Added a few small fixes on top, and merged.
Currently, arrays are transformed into a string with the following format: '[elem1, elem2]'.
Unfortunately, Postgres wants you to use curly braces for arrays (for example, '{elem1, elem2}') and the current implementation throws an error when trying to execute an insert/update on columns with an array type.
This change uses a helper method from Sequel to convert an array to a Postgres compatible array.
Postgres Arrays docs: http://www.postgresql.org/docs/9.3/static/arrays.html
Sequel pg_array docs: http://sequel.jeremyevans.net/rdoc-plugins/files/lib/sequel/extensions/pg_array_rb.html