ecto_enum
ecto_enum copied to clipboard
Compile error
While documentation says this should be possible, I'm getting query compilation errors here.
iex(1)> import Ecto.Query
Ecto.Query
iex(2)> from(v in Videos, where: v.visibility == :public)
** (Ecto.Query.CompileError) `:public` is not a valid query expression
(ecto 3.3.2) expanding macro: Ecto.Query.where/3
iex:2: (file)
(ecto 3.3.2) expanding macro: Ecto.Query.from/2
iex:2: (file)
There are multiple workaround for this, but does anybody have a clue why this happens?
Thank you
This is not related to ecto_enum. You must pin the value you want to use in from/2
.
Doing the following should work:
iex(1)> import Ecto.Query
Ecto.Query
iex(2)> from(v in Videos, where: v.visibility == ^:public)
(notice the caret before :public
)
Thanks for explanation