Opened 6 years ago

Closed 6 years ago

#13585 closed (invalid)

Documentation explaining return value of update() run on a QuerySet is inaccurate

Reported by: bpp198 Owned by: nobody
Component: Documentation Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:



"The update() method is applied instantly and returns the number of rows affected by the query."

The actual return value depends on the database backend. MySQL, for example, will always return 1 if the query is successful, regardless of the number of affected rows.

Doc patch attached.

Attachments (1)

0001.Correct-update-on-queryset-return-value-documentation.patch (1023 bytes) - added by bpp198 6 years ago.
Documentation change.

Download all attachments as: .zip

Change History (2)

Changed 6 years ago by bpp198

Documentation change.

comment:1 Changed 6 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Did you actually try it?

>>> Cat.objects.filter(status='Adopted',avail=True)
[<Cat: Bedford>, <Cat: Odessa>, <Cat: Yates>, <Cat: Cleo>, <Cat: Carmen (now Snicker)>, <Cat: Bingo>]
>>> Cat.objects.filter(status='Adopted',avail=True).update(avail=False)
>>> Cat.objects.filter(status='Adopted',avail=True)

This is a MySQL project, so the documentation appears to be correct. The ORM is apparently doing something to compensate for MySQL's difference here.

Note: See TracTickets for help on using tickets.
Back to Top