Skip to content

Cannot use enum values in JSON without explicit casts #3439

@lukaseder

Description

@lukaseder

Try this:

create domain e as enum ('a', 'b');
select cast ('a' as e);
select json_array(cast('a' as e));

I would expect the query to produce ["a"], but it fails with:

SQL Error [22018] [22018]: Data conversion error converting "ENUM to JSON"

As a workaround, I can cast the enum value back to VARCHAR explicitly, but I think that should work out of the box?

select json_array(cast(cast('a' as e) as varchar));

Is there any other reasonable auto conversion from an enum value to a json value that I might be overlooking?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions