-
Notifications
You must be signed in to change notification settings - Fork 59
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
Enum conversion inconsistencies #60
Comments
Thanks for the bug report! Sure enough, that violates the Principle of Least Astonishment, and is a change in behavior from 0.7.x. I dug in a little, and created this Django ticket about this: https://code.djangoproject.com/ticket/26807 |
Turns out the future-deprecated SubfieldBase class did more than what was initially thought. Since it is removed in Django 1.10+, for clarity we no longer use it at all. Instead we intern the behavior of its `Creator` descriptor class as `CastOnAssignDescriptor`. Fixes #60 Refs https://code.djangoproject.com/ticket/26807 Refs 8260050
Turns out the future-deprecated SubfieldBase class did more than what was initially thought. Since it is removed in Django 1.10+, for clarity we no longer use it at all. Instead we intern the behavior of its `Creator` descriptor class as `CastOnAssignDescriptor`. Fixes #60 Refs https://code.djangoproject.com/ticket/26807 Refs 8260050
Turns out the future-deprecated SubfieldBase class did more than what was initially thought. Since it is removed in Django 1.10+, for clarity we no longer use it at all. Instead we intern the behavior of its `Creator` descriptor class as `CastOnAssignDescriptor`. Test cases and original bug report by @andrewdodd. Thanks! Fixes #60 Refs https://code.djangoproject.com/ticket/26807 Refs 8260050
@andrewdodd: This is fixed in 0.8.1 |
Holy moly that was quick! I dug a little into this on the weekend and came up with the same idea... that one would have to re-implement the SubfieldBase/Creator code, which felt bad. Thanks! |
@andrewdodd Yeah, it felt strange, but looks like that's the way to go nevertheless -- and at the very least it fixes things for the time being. |
When upgrading from 0.7.4 to 0.8.0 I found that the behaviour of enum fields has changed if you are initialising them via their String value rather than by their enum type.
This behaviour was a side effect of the changes to remove the deprecated SubfieldBase (8260050).
I have had a short attempt at fixing this but haven't managed to find a way. (I'm thinking from my reading of the SubfieldBase related material that it might have something to do with replacing the
__new__
method).I have written a test to demonstrate the issue:
To see the failure copy this test into a file in the
tests
directory and runTo see it pass, checkout 0.7.4 and run it again!
The text was updated successfully, but these errors were encountered: