Add Record en-/decoder

Issue #258 new
Lars Kanis
created an issue

Original post: https://groups.google.com/forum/#!topic/ruby-pg/ikdlp67c5RA

The current implementation of decoders and encoders doesn't support embedded Records of composite type?

What I'd like to do is decode the following example:

CREATE TYPE example AS (a string, b integer, c boolean);
CREATE TABLE test (id integer, sample example);
INSERT INTO test VALUES (1, '("Some text",123,false)');
SELECT * FROM test;

The query returns the following values, before decoder:

result['id'] === 1
result['sample'] === '("Some text",123,false)'

What I'd like to do is something like the "PG::TextDecoder::Array#decode" method, but with a mix of decoder functions, returning:

result['sample'] === ['Some text', 123, false]

Comments (2)

  1. Lars Kanis reporter

    The postgres implementation is in rowtypes.c. We need a new Coder type next to PG::SimpleCoder, PG::CopyCoder and PG::CompositeCoder. I would call it PG::RowCoder. I haven't got it further so far - still around 30%.

  2. Log in to comment