Skip to content

How to define a string enum field? #241

@Nicolab

Description

@Nicolab

Hello,

I can't find a way to define an enum with Crecto.

PostgreSQL type:

CREATE TYPE enum_lang AS ENUM('en', 'fr');

The column:

enum_field :enum_lang, Langs, column_name: "lang", column_type: String

Enum:

enum Langs
      EN
      FR
    end

Error:

Unhandled exception: PG::ResultSet#read returned a Slice(UInt8). A (String | Nil) was expected. (Exception)

If i naively replace String by Slice(Uint8), an error occurred because Slice(Uint8) is not a supported type in Crecto.

Please, how am I supposed to handle this enum?

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