#21852 closed Bug (fixed)
Migration serializer cannot handle iterators
Reported by: | Markus Holtermann | Owned by: | Markus Holtermann |
---|---|---|---|
Component: | Migrations | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | info@… | Triage Stage: | Ready for checkin |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
If the choices attribute of a model field is an iterable (not list
, tuple
, etc, but a e.g. a generator) the migration writer fails lacking a serialization path.
I suggest to serialize the iterable as a tuple.
Change History (6)
comment:1 by , 11 years ago
Status: | new → assigned |
---|
comment:2 by , 11 years ago
Summary: | Migration serializer cannot handle iterables → Migration serializer cannot handle iterators |
---|
comment:3 by , 11 years ago
Triage Stage: | Unreviewed → Ready for checkin |
---|
I can reproduce the issue.
The proposed patch looks good: the added test fails with current master and passes after applying the patch.
I wonder however if collections.Iterator
should be used instead of collections.Iterable
, but that's just nitpicking.
I'll mark this as ready for checkin
and try to get a second set of eyes to check it out before committing.
Thanks.
comment:4 by , 11 years ago
Thanks bmispelon,
Looking at the collections documentation the table shows, that e.g. a Sequence
is an Iterable
but not an Iterator
. That's why I'd stay with Iterable
.
comment:5 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Pull request is at https://github.com/django/django/pull/2198