I'm need to find a Ruby ORM (Active Record, Sequel, etc) that supports PostgreSQL's Array column datatype.
http://www.postgresql.org/docs/8.2/int开发者_StackOverflow中文版eractive/arrays.html
Any tips?
Sequel's sql_subscript
is just for accessing values when querying, as you mentioned in an earlier comment.
Sequel doesn't have special support for database arrays other than that. You can create arrays in create_table blocks:
DB.create_table do
column :numbers, 'integer[]'
end
But that's not special support as Sequel is just passing the type through. There's no built-in support for taking a ruby array and turning it into an PostgreSQL array when building a query, and there's also no support for turning the PostgreSQL array into a ruby array when retrieving (it'll be returned as a string).
That being said, Sequel is set up so that extensions for PostgreSQL's array and hstore types that offer full integration could be implemented with relative ease. Someone has been working on support for hstore (I think it's finished or close to it, but I haven't reviewed it yet), and support for arrays should be similar to that. It's likely that a future version of Sequel will ship with such support either by default or available as an official extension.
Sequel supports this through the sql_subscript
method on Symbols (and others).
Support was originally added in release 0.4.3 (2007-Dec) via Symbol#|
and Symbol#/
, but was changed to use the new method in release 2.12.0 (2009-Apr). Search the CHANGELOG for more mentions of improvements that have occurred over time.
精彩评论