#23386: Unexpected result when incrimenting field with F expression
-------------------------------+--------------------
     Reporter:  codefisher     |      Owner:  nobody
         Type:  Uncategorized  |     Status:  new
    Component:  Uncategorized  |    Version:  1.6
     Severity:  Normal         |   Keywords:
 Triage Stage:  Unreviewed     |  Has patch:  0
Easy pickings:  0              |      UI/UX:  0
-------------------------------+--------------------
 I would have thought these two expresses would be exactly the same, except
 the second would be more efficient.

 A: some_model.some_field += 1
 B: some_model.some_field = F('some_field') + 1

 I hit some unexpected behaviour when, I did this

 some_model.save()
 # and somewhere far far away
 some_model.save()

 With A, the field is incremented once, as I expected.  But with B, it gets
 incremented twice.  I would have expected the F query to effect the next
 database call, and nothing more.  It might be intended, but then it is not
 documented.

 I could write some come to demonstrate this.  I only noticed it because I
 was using an import script that was creating lots of objects, and I had A
 and B in the model's overridden save method. They were causing vastly
 different results.

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

Reply via email to