#26609: Spurious migrations cause by non-deteministic field choices order
----------------------------------------------+------------------------
Reporter: hjwp | Owner: nobody
Type: Bug | Status: new
Component: Database layer (models, ORM) | Version: 1.9
Severity: Normal | Keywords: migrations
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+------------------------
Not sure if this is *quite* a bug, but thought I'd mention it since it was
a puzzler.
I had an app that seemed to be generatic infinite migrations, ie
"makemigrations" would always create new migrations even if I didn't do
anything about it.
Eventually I figured out it was (I think) due to Python's non-
deterministic dict ordering behaviour (this may be Python 3 only, IIRC
said nondetermininstic ordering is to avoid some sort of security thing).
code, eg:
{{{
THINGS = {
'key1': 'val1',
'key2': 'val2',
#etc
}
# ...
myfield = models.CharField(choices=[(k,v) for k,v in THINGS],
max_length=255)
}}}
I fixed it by using "sorted" on my list comprehension, but I imagine other
people might be v confused, and it feels like something ppl are quite
likely to do (use a dict for the basis of choices in a field?)
--
Ticket URL: <https://code.djangoproject.com/ticket/26609>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/047.4901881e010aef993764becb7e506344%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.