#26521: CreateModel allows duplicate field names
-------------------------------+--------------------
     Reporter:  w0rp           |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Migrations     |    Version:  1.9
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 I hit this bug while manually editing a migration file after squashing
 files. If you define the same field twice in a list of fields for
 CreateModel, then migrate will take the second field definition without
 reporting any errors.

 {{{#!python
 class Migration(migrations.Migration):
     operations = [
         migrations.CreateModel(
             name='Foo',
             fields=[
                 ('id', models.AutoField(verbose_name='ID',
 serialize=False, auto_created=True, primary_key=True)),
                 ('created', models.DateTimeField(auto_now_add=True,
 db_index=True)),
                 # This one will be used.
                 ('created', models.DateField(auto_now_add=True,
 db_index=True)),
             ],
         ),
     ]
 }}}

 I think the migration code should check for duplicate fields, and then
 report an error if you have mistakenly defined the same field twice for
 the fields array.

--
Ticket URL: <https://code.djangoproject.com/ticket/26521>
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.de9e697d492df317051b81420f6af80a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to