gjaldon / ecto_enum

Ecto extension to support enums in models
MIT License
562 stars 131 forks source link

unable to parse short-cut way enum #79

Closed msudgh closed 5 years ago

msudgh commented 5 years ago

ecto migration tool isn't able to parse defined enum as the following:

import EctoEnum

defenum PatronStatusEnum, "disable", "enabled", "kicked"

Result:

432hz :: w/test/blinder ‹master*› » mix ecto.migrate                            1 ↵
Compiling 17 files (.ex)

== Compilation error in file lib/ecto_enum.ex ==
** (Protocol.UndefinedError) protocol Enumerable not implemented for "enabled"
    (elixir) lib/enum.ex:1: Enumerable.impl_for!/1
    (elixir) lib/enum.ex:141: Enumerable.reduce/3
    (elixir) lib/enum.ex:311: Enum.all?/2
    lib/ecto_enum.ex:4: (file)
    (elixir) lib/kernel/parallel_compiler.ex:208: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/6

what's wrong with defined enum?


Elixir: 1.8.2 phoenix_ecto: 4.0 ecto_sql: 3.0

gjaldon commented 5 years ago

The code should be:

import EctoEnum
defenum PatronStatusEnum, ["disabled", "enabled", "kicked"]