kysely-data-api icon indicating copy to clipboard operation
kysely-data-api copied to clipboard

Support for Array of Enums

Open jamlen opened this issue 2 years ago • 1 comments

I want to define a column which is an array of enum values, but whilst I can create the table and execute an INSERT, I can’t select the record back and I get this error

BadRequestException: Array of type 'zones' is not supported

and it fails in the Console RDS window if I just try SELECT * FROM product.

Here is a sql fiddle of what I'm trying to support

See discussion on slack here

jamlen avatar Jun 20 '22 12:06 jamlen

One workaround is to cast the enum type to a text type before aggregating it into an array. For instance, if your enum type is called my_enum_type, you could do this:

SELECT some_column, array_agg(my_enum_column::text) AS enum_array
FROM your_table
GROUP BY some_column;

omikader avatar Jan 17 '24 18:01 omikader