Closed gajus closed 6 years ago
attname
is of type name
:
=> \d pg_attribute Table "pg_catalog.pg_attribute" Column | Type | Collation | Nullable | Default ---------------+-----------+-----------+----------+--------- attrelid | oid | | not null | attname | name | | not null | ⋮
Find the OID for an array of the type as described in the pg-types README:
=> SELECT typname, oid, typarray FROM pg_type WHERE typname = 'name'; typname | oid | typarray ---------+-----+---------- name | 19 | 1003 (1 row)
Set the parser:
const OID_ARRAY_TEXT = 1009;
const OID_ARRAY_NAME = 1003;
pg.types.setTypeParser(OID_ARRAY_NAME, pg.types.getTypeParser(OID_ARRAY_TEXT));
See also https://github.com/brianc/node-pg-types/issues/56#issuecomment-323223477.
You can just select it as an array of text
, too.
SELECT …, array_agg(a1.attname)::text[] "columnNames", …
Thank you for taking time to explain.
Expecting
columnNames
to return an array.Returns
{foo, bar}
instead of expected array.I couldn't figure out how to configure
setTypeParser
to capture this expression.