Opened 18 years ago
Closed 18 years ago
#4858 closed (fixed)
Add support for ~ to Q objects for negation
| Reported by: | Owned by: | nobody | |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev | 
| Severity: | Keywords: | qs-rf-fixed | |
| Cc: | elsdoerfer@… | Triage Stage: | Accepted | 
| Has patch: | yes | Needs documentation: | no | 
| Needs tests: | no | Patch needs improvement: | no | 
| Easy pickings: | no | UI/UX: | no | 
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 (2)
Change History (10)
by , 18 years ago
| Attachment: | 4858.patch added | 
|---|
comment:1 by , 18 years ago
| Has patch: | set | 
|---|
comment:2 by , 18 years ago
| Summary: | Add support for ~ to Q objects → Add support for ~ to Q objects for negation | 
|---|---|
| Triage Stage: | Unreviewed → Design decision needed | 
comment:4 by , 18 years ago
| Keywords: | qs-rf added | 
|---|---|
| Triage Stage: | Design decision needed → Accepted | 
comment:5 by , 18 years ago
| Keywords: | sprintsept14 added | 
|---|---|
| Triage Stage: | Accepted → Ready for checkin | 
comment:6 by , 18 years ago
comment:7 by , 18 years ago
| Keywords: | qs-rf-fixed added; qs-rf sprintsept14 removed | 
|---|---|
| Triage Stage: | Ready for checkin → Accepted | 
Moving back to accepted so it doesn't get checked in on trunk. It's already fixed on the queryset-refactor branch.
comment:8 by , 18 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
(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
Interesting idea, Colin. Can you raise this on django-developers?