fuelen / ecto_erd

A mix task for generating Entity Relationship Diagram from Ecto schemas available in your project.
Apache License 2.0
215 stars 15 forks source link

Improves support for Ecto.Enum types #16

Closed jaimeiniesta closed 2 years ago

jaimeiniesta commented 2 years ago

Adds a function clause to match the new internal representation in Ecto.Enum.

For example, we can now handle this:

{:parameterized, Ecto.Enum,
  %{
    mappings: [foo: "foo", bar: "bar"],
    on_cast: %{"foo" => :foo, "bar" => :bar},
    on_dump: %{foo: "foo", bar: "bar"},
    on_load: %{"foo" => :foo, "bar" => :bar},
    type: :string
  }
}

Will be represented as #Enum<[:foo, :bar]>

Fixes https://github.com/fuelen/ecto_erd/issues/14

fuelen commented 2 years ago

Hey @jaimeiniesta Thank you for the fix. I think we can use on_dump instead of converting mappings to map. Additionally, on_dump exists in the previous version of Ecto.Enum type, so we can use the same function head to support both versions.