ecto_enum icon indicating copy to clipboard operation
ecto_enum copied to clipboard

Compile error

Open char0n opened this issue 5 years ago • 2 comments

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

char0n avatar Feb 17 '20 14:02 char0n

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)

nicklayb avatar Mar 17 '20 01:03 nicklayb

Thanks for explanation

char0n avatar Mar 17 '20 08:03 char0n