How do i query custom data type?

Hi, I got a question how to query my custom data type.

for example in ecto I made a custom schema that has this word list like this.

defmodule Example.One do
  use Ecto.Schema
  import Ecto.Changeset

  **@example ~w(a b c d)a**

  schema "hello" do
    field(:result, Ecto.Enum, values: @example , default: :a)


    timestamps(type: :utc_datetime_usec)

And now I want to do some querys in postsql(actually usind dbeaver)

select * from hello h where h.result = a

But this didn’t work and says there is no column which has name a.

How do I query this atom word list type?

Hi @menw whenever you get an error please provide both:

  1. The code you wrote that generated the error
  2. The error

This applies even if the code and error isn’t Elixir.

Postgres doesn’t have an atom type, and Ecto doesn’t actually make it a custom type, I’m pretty sure it’s just a string. Really though this depends on your migration.


Surround the a value with single quotes.