gjaldon / ecto_enum

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

Support Composite types in Postgres #89

Open gjaldon opened 5 years ago

gjaldon commented 5 years ago

It would be nice to be able to express in Ecto a datatype like:

:unused | {:next, id} | :finished
Eiji7 commented 5 years ago

How it's going to work? If I remember correctly composite types have fixed number of attributes, right?

Did you mean: {:unused, nil} | {:next, id} | {:finished, nil}? If so then I believe that it should not be implemented in such library. In same way you would require all ecto types have such support which does not makes sense especially if we are talking about complex combinations.

The better way is to create your own ecto type instead. Remember that you can reuse existing ecto callback implementations when defining your own cast, dump and load functions.