Opened 12 years ago

Closed 12 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: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no



"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 12 years ago.
Documentation change.

Download all attachments as: .zip

Change History (2)

Changed 12 years ago by bpp198

Documentation change.

comment:1 Changed 12 years ago by Karen Tracey

Resolution: invalid
Status: newclosed

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