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 Marco Bonetti, 6 years ago

Summary: Documentation sould mention that cloning a QuerySet retains the underlying databaseDocumentation should mention that cloning a QuerySet retains the underlying database

comment:2 by Claude Paroz, 6 years ago

Easy pickings: set
Triage Stage: UnreviewedAccepted
Type: UncategorizedCleanup/optimization

comment:3 by Tim Graham, 6 years ago

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.

comment:4 by Simon Charette, 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 Marco Bonetti, 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 Marco Bonetti, 6 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.
Back to Top