#29051: unique_together behavior undocumented changes in 1.11
------------------------------------+--------------------------------------
     Reporter:  Christian Pedersen  |                    Owner:  nobody
         Type:  Bug                 |                   Status:  new
    Component:  Uncategorized       |                  Version:  1.11
     Severity:  Normal              |               Resolution:
     Keywords:                      |             Triage Stage:  Unreviewed
    Has patch:  0                   |      Needs documentation:  0
  Needs tests:  0                   |  Patch needs improvement:  0
Easy pickings:  0                   |                    UI/UX:  0
------------------------------------+--------------------------------------

Comment (by Christian Pedersen):

 Replying to [comment:1 Tim Graham]:
 > I'm not sure what you mean -- can you give specific steps to reproduce
 the problem? The release note you mentioned is from
 267dc4adddd2882182f71a7f285a06b1d4b15af0. Is it that same commit that's
 causing your problem?

 Of course. Give this simplified model:
 {{{
 class MyModel(models.Model):
     field1 = models.ForeignKey(FModel, on_delete=models.CASCADE)
     field2 = models.CharField()
     field3 = models.CharField(blank=True, null=True)

     class Meta:
         unique_together = (("field1", "field2", "field3"),)

 }}}

 It is possible to do:
 {{{
 MyModel.objects.create(field1=ref, field2='Name', field3=None)
 MyModel.objects.create(field1=ref, field2='Name', field3=None)
 }}}
 and it will insert this model twice. In Django 1.10 this wouldn't happen,
 as Django would check all three fields. However in 1.11 it seems to
 emulate how PostgreSQL does it.
 My problem with this is that it's an undocumented change and the only
 other mention of it I could find was marked as "wontfix".

 I believe the commit you mention is the one that changes this behavior.
 Probably these lines:
 
https://github.com/django/django/commit/267dc4adddd2882182f71a7f285a06b1d4b15af0
 #diff-bf776a3b8e5dbfac2432015825ef8afeR1090

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29051#comment:2>
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/066.7338639bae42a135f88d092fad43b5e2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to