Opened 15 years ago

Closed 15 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

Description

From http://docs.djangoproject.com/en/dev/topics/db/queries/

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

Download all attachments as: .zip

Change History (2)

by bpp198, 15 years ago

Documentation change.

comment:1 by Karen Tracey, 15 years ago

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)
6L
>>> 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