#32554: Add Q.TRUE, Q.FALSE, Q.any() and Q.all()
-------------------------------------+-------------------------------------
Reporter: jonathan- | Owner: nobody
golorry |
Type: New | Status: new
feature |
Component: Database | Version: dev
layer (models, ORM) |
Severity: Normal | Keywords: Q objects, any, all
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
`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.
--
Ticket URL: <https://code.djangoproject.com/ticket/32554>
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/059.bf7deb6a5bbde859eb48f453a5b31120%40djangoproject.com.