Django

Code

Ticket #3283 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

[patch] creating an empty queryset

Reported by: medhat Assigned to: adrian
Milestone: Component: Database wrapper
Version: SVN Keywords: empty queryset
Cc: gary.wilson@gmail.com Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

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

empty_queryset.patch (1.8 kB) - added by medhat on 01/11/07 05:08:35.
empty_in_clause.patch (3.2 kB) - added by medhat on 01/11/07 05:25:44.
another solution for the empty in-clause using empty querysets
empty_queryset_2.patch (7.1 kB) - added by medhat on 01/11/07 09:58:56.
this should replace the two previous patches, it contains both patches, documentation, and tests.
empty_queryset_3.patch (7.9 kB) - added by medhat on 01/11/07 10:16:49.
Yet another version of the patch that fixes a problem with QNot (with tests)

Change History

01/11/07 05:08:35 changed by medhat

  • attachment empty_queryset.patch added.

01/11/07 05:25:44 changed by medhat

  • attachment empty_in_clause.patch added.

another solution for the empty in-clause using empty querysets

01/11/07 05:28:42 changed by medhat

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.

01/11/07 05:30:32 changed by medhat

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 :-)

01/11/07 09:58:56 changed by medhat

  • attachment empty_queryset_2.patch added.

this should replace the two previous patches, it contains both patches, documentation, and tests.

01/11/07 10:16:49 changed by medhat

  • attachment empty_queryset_3.patch added.

Yet another version of the patch that fixes a problem with QNot (with tests)

01/18/07 14:53:02 changed by SmileyChris

  • stage changed from Unreviewed to Ready for checkin.

Stellar patch.

01/21/07 23:50:08 changed by Gary Wilson <gary.wilson@gmail.com>

  • cc set to gary.wilson@gmail.com.

Yes, very nice.

01/22/07 20:09:17 changed by adrian

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.

01/22/07 20:11:46 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [4394]) Fixed #3283 -- Added support for empty QuerySets? via none() method. Thanks for the patch, medhat


Add/Change #3283 ([patch] creating an empty queryset)




Change Properties
Action