#32554: Add Q.TRUE, Q.FALSE, Q.any() and Q.all()
-------------------------------------+-------------------------------------
Reporter: jonathan-golorry | Owner: jonathan-
| golorry
Type: New feature | Status: assigned
Component: Database layer | Version: dev
(models, ORM) |
Severity: Normal | Resolution:
Keywords: Q objects, any, all | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 1
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by jonathan-golorry):
* owner: nobody => jonathan-golorry
* needs_docs: 0 => 1
* has_patch: 0 => 1
* status: new => assigned
Old description:
> `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).
>
> 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
>
> My patch relies on https://code.djangoproject.com/ticket/32548 and
> https://code.djangoproject.com/ticket/32549. I kept those as separate
> tickets because they each had side effects that warranted their own
> discussion.
New description:
`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/14131
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
My patch relies on https://code.djangoproject.com/ticket/32548 and
https://code.djangoproject.com/ticket/32549. I kept those as separate
tickets because they each had side effects that warranted their own
discussion.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32554#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/074.8ded6bcbdedbda0e96247276504b244a%40djangoproject.com.