Some general responses to your points:
Database support
Yep, not all databases support enums and not all support them the same
way. That's par for the course when you're trying to abstract across
multiple implementations of the same pseudo-standard.
Vendor lock-in
Enums are hardly vendor lock-in, they're a language feature that
happens to require a library in order to support backwards
compatibility. I accept the fact that there may be changes to it in
the near future, but even if there are, there can't be any breaking
changes to the API.
Ordering
Yes you can't do
sorted(qs, key=lambda o: o.my_enum_field)
But you can do
sorted(qs, key=lambda o:
o.my_enum_field.name)
which will give you the same result as the database ordering, or
sorted(qs, key=lambda o: o.my_enum_field.value),
if you want to sort according to the values.
Migrations
Yep, a bit of a pain in the neck to support changing enum definitions,
but in general any _sane_ developer would only ever add values to an
enum after it was initially created, and you could make
`AddValueToEnum` a non-reversible operation.
I admit it does create some expectations about other places that
migrations would require more "intelligence", but extensions to the
original implementation are an inevitability and I'm sure you're quite
aware of that.
On that note, I'm kind of worried about your assertion that types in
contrib libraries aren't required to support automatic migration.
Since migrations were added, we've added support for migrations in
most of our custom field types.
Philosophy
I try to keep myself out of philosophical arguments. Reference tables
have a purpose (when you're dealing with a set of values that aren't
fully known when you're defining the dataset (eg. custom application
error code tables)), but when the dataset _is_ known in advance an
enum will save you a couple of joins per table lookup.
It depends what you guys want to do. I'm happy to put in the work to
make the implementation generic, but I'm not going to push for you
guys to implement something you don't want or don't think provides
real value for users. Contributing to contrib.postgres is a possible
option, but it's not really a postgres specific feature -- almost all
of the major database vendors support it (sqlite being as always the
obvious exception).
Thomas
>
https://groups.google.com/d/msgid/django-developers/CAMwjO1GAG88_%3DLFRibpO6uabUmCb7eprByWRZyjECdV2jHbcxg%40mail.gmail.com.