ForbesLindesay/atdatabases

PG: Parse enum arrays columns

avaly opened this issue · 0 comments

Currently, only primitive array columns are parsed and returned with the expected type by @database/pg. Columns defined as an array of a custom enum type are returned as a string.

CREATE TYPE test_enum AS ENUM ('foo', 'bar', 'ham');

CREATE TABLE test_types (
  id UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(),
  scores INTEGER[],
  enums test_enum
);

INSERT INTO test_types (scores, enums) VALUES ('{1, 5, 10}', '{foo, bar}');

Running a simple SELECT via @databases/pg returns the following result:

[
   {
       id: 'af821378-5077-4624-8048-2a951399daec',
       scores: [ 1, 5, 10 ],
       enums: '{foo,bar}'
    }
]