Opened 19 years ago
Closed 19 years ago
#3283 closed enhancement (fixed)
[patch] creating an empty queryset
| Reported by: | medhat | Owned by: | Adrian Holovaty |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | normal | Keywords: | empty queryset |
| Cc: | gary.wilson@… | Triage Stage: | Ready for checkin |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
This patch will allow returning an empty queryset from the manager. This way, if in a situation you know that the result of the queryset will be empty you can return the empty queryset instead of using something like 'where 1=0' which will still hit the database.
You can check this thread for a brief discussion about this Creating an empty queryset
Attachments (4)
Change History (10)
by , 19 years ago
| Attachment: | empty_queryset.patch added |
|---|
by , 19 years ago
| Attachment: | empty_in_clause.patch added |
|---|
comment:1 by , 19 years ago
I have also added another fix for the empty in-clause #2473 using the empty queryset. This fix will not hit the database at all.
comment:2 by , 19 years ago
well, I just realized that my empty-in-clause patch is not dependent on the empty-queryset patch! I guess I need to get some sleep :-)
by , 19 years ago
| Attachment: | empty_queryset_2.patch added |
|---|
this should replace the two previous patches, it contains both patches, documentation, and tests.
by , 19 years ago
| Attachment: | empty_queryset_3.patch added |
|---|
Yet another version of the patch that fixes a problem with QNot (with tests)
comment:5 by , 19 years ago
What a nice patch. Only thing missing is a "**New in Django development version**" note in the documentation, as per our style, but I'll take care of that.
comment:6 by , 19 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
another solution for the empty in-clause using empty querysets