Opened 5 years ago
Last modified 5 years ago
#32554 closed New feature
Add Q.TRUE, Q.FALSE, Q.any() and Q.all() — at Version 2
| Reported by: | jonathan-golorry | Owned by: | jonathan-golorry |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Normal | Keywords: | Q objects, any, all |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | yes | Needs documentation: | yes |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Q.empty() checks for nested empty Q objects such as Q(Q()). See #32549 for rationale.
Q.FALSE and Q.TRUE are classattribute aliases for Q(pk__in=[]) and ~Q(pk__in=[]).
Q.any() and Q.all() mimic python's builtin any and all, defaulting to Q.FALSE and Q.TRUE for empty iterators (or iterators containing only empty Q objects).
Patch: https://github.com/django/django/pull/14159
See this forum thread discussing why these are an improvement over many ad-hoc implementations people are using: https://forum.djangoproject.com/t/improving-q-objects-with-true-false-and-none/851
Change History (2)
comment:1 by , 5 years ago
| Description: | modified (diff) |
|---|---|
| Has patch: | set |
| Needs documentation: | set |
| Owner: | changed from to |
| Status: | new → assigned |
comment:2 by , 5 years ago
| Description: | modified (diff) |
|---|