#35854: Order of "choices" on CharField randomly changing forcing new migrations
despite no changes.
-----------------------------------+--------------------------------------
     Reporter:  WoosterInitiative  |                     Type:  Bug
       Status:  new                |                Component:  Migrations
      Version:  5.1                |                 Severity:  Normal
     Keywords:  CharField          |             Triage Stage:  Unreviewed
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------
 I have a field `attachment_type` in a class that uses

 {{{
 TYPE_CHOICES = {
         ("image", "Image"),
         ("document", "Document"),
         ("audio", "Audio"),
         ("video", "Video"),
     }
 }}}

 Every `makemigrations` call generates a new migration for that field:

 {{{
 migrations.AlterField(
             model_name="genericattachment",
             name="attachment_type",
             field=models.CharField(
                 choices=[
                     ("audio", "Audio"),
                     ("document", "Document"),
                     ("video", "Video"),
                     ("image", "Image"),
                 ],
                 default="image",
                 max_length=10,
             ),
         ),
 }}}

 I noticed that the order of the choices in the migration changes every
 time. It doesn't seem to have a consistent method to compare the set of
 tuples properly and so it generates a new migration every time. I have not
 yet observed that it even accidentally collides in a way that does not
 generate a new one.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35854>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/01070192b05fdf31-6c2397dc-2abe-4ccc-9d78-63ca3300eb2d-000000%40eu-central-1.amazonses.com.

Reply via email to