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)
Change History (2)
by , 15 years ago
Attachment: | 0001.Correct-update-on-queryset-return-value-documentation.patch added |
---|
comment:1 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | new → 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) 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.
Documentation change.