Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves support for Ecto.Enum types #16

Merged
merged 2 commits into from
Feb 17, 2022
Merged

Conversation

jaimeiniesta
Copy link
Contributor

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 #14

@fuelen
Copy link
Owner

fuelen commented Feb 17, 2022

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.

@fuelen fuelen merged commit e3705e0 into fuelen:main Feb 17, 2022
@jaimeiniesta jaimeiniesta deleted the fix-enum branch February 17, 2022 19:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ecto.Enum types not supported
2 participants