Re: [Django] #32554: Add Q.TRUE, Q.FALSE, Q.any() and Q.all()

2021-03-19 Thread Django
#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
-+-
Description changed by jonathan-golorry:

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).
>
> 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.

New description:

 `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

--

-- 
Ticket URL: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/074.187dbfd81a0db8f80f6dcb923199dd80%40djangoproject.com.


Re: [Django] #32554: Add Q.TRUE, Q.FALSE, Q.any() and Q.all()

2021-03-15 Thread Django
#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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/074.8ded6bcbdedbda0e96247276504b244a%40djangoproject.com.


[Django] #32554: Add Q.TRUE, Q.FALSE, Q.any() and Q.all()

2021-03-15 Thread Django
#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: 
Django 
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/059.bf7deb6a5bbde859eb48f453a5b31120%40djangoproject.com.