On Wednesday, April 11, 2012 10:35:10 AM UTC-7, Jeremy Evans wrote: > I can't see of a way to handle this on a generalized basis, such that you > could just load an extension and row types would be handled correctly > automatically. At the very least, you'll need to tell Sequel what the type > and field names to use for the row. You can use the pg_array/pg_hstore > extensions as a guide for what to do. I imagine the API like this: > > Sequel.extension :pg_composite_types > > # Sequel::Postgres::CompositeType method returns a subclass for the > # specific row type. The block given to the method is handled similarly > # to a create table block, using instance eval, setting the names and > # types of the fields in order. > # > # This method would also populate Sequel::Postgres::NAMED_TYPES > # with a callable for the :type_name so that the Database object > # would transform the value into an instance of the class. > Sequel::Postgres::CompositeType(:type_name) do > Integer :field1 > String :field2 > Float :field3 > end > > I don't have plans to implement this myself in the near future, but if > someone else wants to write the extension, I'll certainly consider it for > inclusion in Sequel. >
Well, I figured out that you can use the pg_type and pg_attribute system tables to get the information, you just need to provide the type name. Once I made that realization, the rest fell into place: https://github.com/jeremyevans/sequel/commit/5994eb8b6e55a8f4a448f5a5b67fc618b8f0f5e2 Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/sequel-talk/-/2xNozD0tpUEJ. 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.
