Record decoder

56 views
Skip to first unread message

Carlos Ferreira da Silva

unread,
Dec 18, 2016, 9:59:02 PM12/18/16
to ruby-pg
The current implementation of decoders and encoders doesn't support embedded Records ou 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]


larskanis

unread,
Dec 28, 2016, 1:36:19 AM12/28/16
to ruby-pg
Hi Carlos,

you're right, there is no coder support for embedded records currently. I'll try to implement it.

--
Kind Regards,
Lars

sbel...@gmail.com

unread,
Jun 7, 2018, 10:14:15 PM6/7/18
to ruby-pg
Carlos,

Did you ever find a solution for this?

Thanks!

Lars Kanis

unread,
Jun 11, 2018, 3:28:49 AM6/11/18
to rub...@googlegroups.com

However there's still not much to track.

--
Regards,
Lars

Carlos Ferreira da Silva

unread,
Aug 18, 2019, 10:44:26 PM8/18/19
to ruby-pg
Well, now that I'm using I'm own GEM, I solved the decode thing over there:
https://github.com/crashtech/torque-postgresql
Reply all
Reply to author
Forward
0 new messages