Django

Code

Ticket #4858 (closed: fixed)

Opened 10 months ago

Last modified 3 weeks ago

Add support for ~ to Q objects for negation

Reported by: Collin Grady <cgrady@the-magi.us> Assigned to: nobody
Component: Database wrapper Version: SVN
Keywords: qs-rf-fixed Cc: elsdoerfer@gmail.com
Triage Stage: Accepted Has patch: 1
Needs documentation: 0 Needs tests: 0
Patch needs improvement: 0

Description

At present there's no quick way to negate a Q object, so if you need something that .filter() and .exclude() can't do, such as Q(A) AND ((NOT Q(B) OR Q(C)), it's a bit awkward as you have to use QNot(Q(B)).

Attached patch would allow Q(A) & (~Q(B) | Q(C)) using the bitwise NOT, similar to the bitwise AND and OR already in use.

Attachments

4858.patch (0.7 kB) - added by Collin Grady <cgrady@the-magi.us> on 07/12/07 16:04:46.
4858.2.patch (2.5 kB) - added by Collin Grady <cgrady@the-magi.us> on 07/13/07 15:56:32.
added docs and tests

Change History

07/12/07 16:04:46 changed by Collin Grady <cgrady@the-magi.us>

  • attachment 4858.patch added.

07/12/07 16:05:20 changed by Collin Grady <cgrady@the-magi.us>

  • has_patch set to 1.

07/12/07 18:26:17 changed by Simon G. <dev@simon.net.nz>

  • summary changed from Add support for ~ to Q objects to Add support for ~ to Q objects for negation.
  • stage changed from Unreviewed to Design decision needed.

Interesting idea, Colin. Can you raise this on django-developers?

07/13/07 15:56:32 changed by Collin Grady <cgrady@the-magi.us>

  • attachment 4858.2.patch added.

added docs and tests

08/10/07 12:34:52 changed by miracle2k

  • cc set to elsdoerfer@gmail.com.

+1 on this.

09/13/07 16:43:30 changed by mtredinnick

  • keywords set to qs-rf.
  • stage changed from Design decision needed to Accepted.

09/15/07 09:09:19 changed by Fredrik Lundh <fredrik@pythonware.com>

  • keywords changed from qs-rf to qs-rf, sprintsept14.
  • stage changed from Accepted to Ready for checkin.

10/14/07 22:32:11 changed by mtredinnick

(In [6518]) queryset-refactor: Added ~ support to Q-objects. Based heavily on a patch from Collin Grady. Refs #4858.

10/14/07 22:37:11 changed by mtredinnick

  • keywords changed from qs-rf, sprintsept14 to qs-rf-fixed.
  • stage changed from Ready for checkin to Accepted.

Moving back to accepted so it doesn't get checked in on trunk. It's already fixed on the queryset-refactor branch.

04/26/08 21:50:16 changed by mtredinnick

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

(In [7477]) Merged the queryset-refactor branch into trunk.

This is a big internal change, but mostly backwards compatible with existing code. Also adds a couple of new features.

Fixed #245, #1050, #1656, #1801, #2076, #2091, #2150, #2253, #2306, #2400, #2430, #2482, #2496, #2676, #2737, #2874, #2902, #2939, #3037, #3141, #3288, #3440, #3592, #3739, #4088, #4260, #4289, #4306, #4358, #4464, #4510, #4858, #5012, #5020, #5261, #5295, #5321, #5324, #5325, #5555, #5707, #5796, #5817, #5987, #6018, #6074, #6088, #6154, #6177, #6180, #6203, #6658


Add/Change #4858 (Add support for ~ to Q objects for negation)




Change Properties
Action