#31874: FK id is not used in update_or_create when id is not used directly
-------------------------------------+-------------------------------------
               Reporter:  erkib      |          Owner:  nobody
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  3.0
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Let's say you have a table
 class Foo(models.Model):
     obj = models.ForeignKey('Bar', on_delete=models.CASCADE)
     x = model.IntegerField()
     y = model.CharField(length=10)
     class Meta:
         unique_together = ('obj', 'x')

 When you use Foo.objects.update_or_create(obj=instance, x=1,
 defaults={'y': 'test'}), the SQL generated will omit the obj_id from WHERE
 clause. On the other hand, when obj_id=10 is used, it is used in WHERE
 clause.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31874>
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/048.e21d83451295e04c6f0a8ed9f6a579d0%40djangoproject.com.

Reply via email to