Skip to content

PG: Parse enum arrays columns #327

@avaly

Description

@avaly

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}'
    }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions