Yeah, you know the type, but you still need to parse the output. On Wed, Sep 21, 2011 at 3:48 PM, Joe Van Dyk <[email protected]> wrote:
> On Wed, Sep 21, 2011 at 3:28 PM, Jeremy Evans <[email protected]> > wrote: > > On Sep 21, 1:57 pm, Joe Van Dyk <[email protected]> wrote: > >> Does sequel support postgresql arrays? What about arrays of custom > >> types? > > > > Sequel's built-in support for arrays is currently limited to the > > sql_subscript method/Sequel::SQL::Subscript class. There's no support > > for handling arrays when retrieved from the database (they are > > returned as strings in the "{...}" format). > > > >> If not, what would it take to get that? > >> > >> I foundhttps://github.com/gucki/sequel_column_type_array, but it's > >> pretty incomplete. > > > > This has the basic idea, using separate classes per array type. I > > wouldn't subclass from Array though. The model he uses shouldn't be > > that hard to work with custom types, but the parser he is using works > > only in trivial cases. He's using the String#parse_csv method from > > FasterCSV (which is ruby 1.9's default CSV class). > > > > True parsing of multiple dimensional PostgreSQL arrays probably > > requires a real parser, and that parser may change depending on the > > the type of the array. It's possible, but it's probably a lot of > > work. > > > > I'm happy to provide advice and/or code review for anyone planning to > > implement PostgreSQL array support, but it's not something I plan to > > implement myself. > > > > Jeremy > > Hm, it would need a parser? pg has support for introspecting the type > of data being returned in the response (PGResult#ftype and > PGResult#fmod). > > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sequel-talk?hl=en. > > -- Peter van Hardenberg San Francisco, California "Everything was beautiful, and nothing hurt." -- Kurt Vonnegut -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
