Opened 6 years ago
Closed 6 years ago
#29481 closed Cleanup/optimization (invalid)
Documentation should mention that cloning a QuerySet retains the underlying database
Reported by: | Marco Bonetti | Owned by: | nobody |
---|---|---|---|
Component: | Documentation | Version: | 2.1 |
Severity: | Normal | Keywords: | using, database, documentation |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | yes | UI/UX: | no |
Description
For example, in the following code…
qs1 = Entry.objects.using('backup') qs2 = qs1.filter(…) qs3 = qs2.filter(…)
… it is not obvious that qs2 and qs3 will "inherit" the underlying database defined in qs1's using() method.
The current documentation on using() fails to mention this.
Change History (6)
comment:1 by , 6 years ago
Summary: | Documentation sould mention that cloning a QuerySet retains the underlying database → Documentation should mention that cloning a QuerySet retains the underlying database |
---|
comment:2 by , 6 years ago
Easy pickings: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
Type: | Uncategorized → Cleanup/optimization |
comment:3 by , 6 years ago
comment:4 by , 6 years ago
I agree with Tim on this one. What behavior were you expecting Marco, to require calling using()
before each filter()
call?
comment:5 by , 6 years ago
Thanks for your feedback. On hindsight it seems pretty obvious that using()
does indeed get inherited by the cloned querysets. Closing.
comment:6 by , 6 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Isn't this consistent with chaining any other queryset method? I don't see why the expected behavior of
using()
would be different or why it would deserve a special mention.