Chris, your idea seems good to me in principle, that is when the Postgres value is of some composite type, that we support it being automatically exposed as a composite value in Perl.

By default I would recommend, keep it simple.

As I recall, DBD::Pg already supports Postgres arrays as Perl arrays, and similarly I would recommend supporting composite type values like you mention, which are structurally tuples, as Perl hash refs for the members.

For a general form for named composite types, I suggest representing a foo like this: "['foo',{bar=>'what',baz=>'ev'}]"; its the simplest form that keeps all the information; the 'foo' part could also be generalized to however fully-qualified entity names are, eg ['public','foo'] for example.

-- Darren Duncan

On 2014-08-24, 8:07 AM, Chris Travers wrote:
Hi everyone;

I am nearing completion on the logic to serialize composite types into textual
representation of tuples for LedgerSMB and I am wondering if there is additional
interest from others who use DBD::Pg.  If there is we would certainly release
the logic and interfaces on CPAN.  So I figured I would ask.

For those who would be interested, I guess I have a few questions:

1.  Do you need Moose or Moo support?
2.  Do you need plain old hashref support?
3.  Do you need bytea support?

If this is unwelcome please ignore but this seemed like a good place to ask
since it is PostgreSQL/Perl-specific and many of you might have thought about
using composite types in this way.

In case it isn't clear what I am talking about is:

given a type:

CREATE TYPE foo (
    bar text,
    baz text
);

and a hashref {bar => 'foo', baz => 'this, or else that'}

it should produce (foo,"this, or else that")

--
Best Wishes,
Chris Travers

Reply via email to