View Source mix postgrex.pg_output.types (postgrex_pgoutput v0.2.0)
Generate a types.exs
from the result of the following query:
postgres=# o lib/postgrex/types.json
postgres=# SELECT row_to_json(r) FROM (SELECT t.oid::INTEGER, t.typname as type, t.typsend as send, t.typreceive as receive, t.typoutput as output, t.typinput as input,
coalesce(d.typelem, t.typelem)::INTEGER as array_elem, coalesce(r.rngsubtype, 0)::INTEGER as base_type, ARRAY (
SELECT a.atttypid
FROM pg_attribute AS a
WHERE a.attrelid = t.typrelid AND a.attnum > 0 AND NOT a.attisdropped
ORDER BY a.attnum
) as comp_elems
FROM pg_type AS t
LEFT JOIN pg_type AS d ON t.typbasetype = d.oid
LEFT JOIN pg_range AS r ON r.rngtypid = t.oid OR (t.typbasetype <> 0 AND r.rngtypid = t.typbasetype)
WHERE (t.typrelid = 0)
AND (t.typelem = 0 OR NOT EXISTS (SELECT 1 FROM pg_catalog.pg_type s WHERE s.typrelid != 0 AND s.oid = t.typelem))
) as r;
postgres=# o