Re: [Django] #31606: Cannot mix Exists expression with keyword arguments to When

2020-05-26 Thread Django
#31606: Cannot mix Exists expression with keyword arguments to When
-+-
 Reporter:  Ryan Heard   |Owner:  Ryan
 |  Heard
 Type:  New feature  |   Status:  closed
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Mariusz Felisiak ):

 * status:  assigned => closed
 * resolution:   => fixed


Comment:

 In [changeset:"587b179d4115f2e4dbc425d1ae035be9eb22197b" 587b179d]:
 {{{
 #!CommitTicketReference repository=""
 revision="587b179d4115f2e4dbc425d1ae035be9eb22197b"
 Fixed #31606 -- Allowed using condition with lookups in When() expression.
 }}}

-- 
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/064.6aa430d7ea3e618e9e264d4ab1bf8e20%40djangoproject.com.


Re: [Django] #31606: Cannot mix Exists expression with keyword arguments to When

2020-05-26 Thread Django
#31606: Cannot mix Exists expression with keyword arguments to When
-+-
 Reporter:  Ryan Heard   |Owner:  Ryan
 |  Heard
 Type:  New feature  |   Status:  assigned
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by felixxm):

 * owner:  nobody => Ryan Heard
 * needs_docs:  1 => 0
 * status:  new => assigned
 * stage:  Accepted => Ready for checkin


-- 
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/064.8ba4c60f77623aeac5b9b21fc1748352%40djangoproject.com.


Re: [Django] #31606: Cannot mix Exists expression with keyword arguments to When

2020-05-25 Thread Django
#31606: Cannot mix Exists expression with keyword arguments to When
-+-
 Reporter:  Ryan Heard   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  1
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by felixxm):

 * needs_docs:  0 => 1


-- 
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/064.ec377da562dba22eebd675ef5f7ee319%40djangoproject.com.


Re: [Django] #31606: Cannot mix Exists expression with keyword arguments to When

2020-05-24 Thread Django
#31606: Cannot mix Exists expression with keyword arguments to When
-+-
 Reporter:  Ryan Heard   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Comment (by felixxm):

 [https://github.com/django/django/pull/12951 PR]

-- 
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/064.62ffd26419c89912b2c8a0f9a36f7fa6%40djangoproject.com.


Re: [Django] #31606: Cannot mix Exists expression with keyword arguments to When

2020-05-21 Thread Django
#31606: Cannot mix Exists expression with keyword arguments to When
-+-
 Reporter:  Ryan Heard   |Owner:  nobody
 Type:  New feature  |   Status:  new
Component:  Database layer   |  Version:  master
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by Simon Charette):

 * type:  Cleanup/optimization => New feature
 * version:  3.0 => master
 * component:  Uncategorized => Database layer (models, ORM)
 * stage:  Unreviewed => Accepted


-- 
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/064.1800cd11e530f03b2696dcd67723030d%40djangoproject.com.


Re: [Django] #31606: Cannot mix Exists expression with keyword arguments to When

2020-05-19 Thread Django
#31606: Cannot mix Exists expression with keyword arguments to When
-+-
 Reporter:  rheard   |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Uncategorized|  Version:  3.0
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Description changed by rheard:

Old description:

> I don't seem to be able to provide an Exists expression to When alongside
> keyword arguments like you can with filter. For instance, consider:
>
> {{{
> class State(models.Model):
>  pass
>
> class County(models.Model):
>   name = CharField(max_length=50)
>   state = ForeignKey(State, related_name='counties')
> }}}
>
> I can execute the following query just fine:
>
> {{{
> County.objects.filter(
>   Exists(State.objects.filter(counties=OuterRef('pk'), name="Texas")),
>   name="Dallas",
> )
> }}}
>
> But a similar query using When does not work:
>
> {{{
> >>> County.objects.annotate(
>   status=Case(
> When(Exists(State.objects.filter(counties=OuterRef('pk'),
> name="Texas")), name="Dallas", then=Value("DALLAS COUNTY")),
> default=Value("ELSEWHERE"),
> ))
> TypeError: When() supports a Q object, a boolean expression, or lookups
> as a condition.
> }}}
>
> Instead the arguments must be wrapped in a Q object:
>
> {{{
> >>> County.objects.annotate(
>   status=Case(
> When(Q(Exists(State.objects.filter(counties=OuterRef('pk'),
> name="Texas")), name="Dallas"), then=Value("DALLAS COUNTY")),
> default=Value("ELSEWHERE"),
> ))
> }}}
>
> This is inconvenient and inconsistent with how filter works, as shown.
>
> When's __init__ method can be modified to allow similar input as filter.
> [https://github.com/rheard/django/commit/978e796bb18414d995d515ab7923831149300977
> Code is in a branch in my repo], but as this is my first time
> contributing to Django, I want to make sure I open a ticket and get
> feedback first.

New description:

 I don't seem to be able to provide an Exists expression to When alongside
 keyword arguments like you can with filter. For instance, consider:

 {{{
 class State(models.Model):
  pass

 class County(models.Model):
   name = CharField(max_length=50)
   state = ForeignKey(State, related_name='counties')
 }}}

 I can execute the following query just fine:

 {{{
 County.objects.filter(
   Exists(State.objects.filter(counties=OuterRef('pk'), name="Texas")),
   name="Dallas",
 )
 }}}

 But a similar query using When does not work:

 {{{
 >>> County.objects.annotate(
   status=Case(
 When(Exists(State.objects.filter(counties=OuterRef('pk'),
 name="Texas")), name="Dallas", then=Value("DALLAS COUNTY")),
 default=Value("ELSEWHERE"),
 ))
 TypeError: When() supports a Q object, a boolean expression, or lookups as
 a condition.
 }}}

 Instead the arguments must be wrapped in a Q object:

 {{{
 >>> County.objects.annotate(
   status=Case(
 When(Q(Exists(State.objects.filter(counties=OuterRef('pk'),
 name="Texas")), name="Dallas"), then=Value("DALLAS COUNTY")),
 default=Value("ELSEWHERE"),
 ))
 }}}

 This is inconvenient and inconsistent with how filter works, as shown.

 When's __init__ method can be modified to allow similar input as filter.
 
[https://github.com/rheard/django/commit/978e796bb18414d995d515ab7923831149300977
 Code is in a branch in my repo], but as this is my first time contributing
 to Django, I want to make sure I open a ticket and get feedback first.

 Also I wasn't sure how to classify this. I wasn't sure if it was a bug, as
 I wasn't sure if it was designed this way.

--

-- 
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/064.1da213bbdc9dede44e80a3295663f50b%40djangoproject.com.


Re: [Django] #31606: Cannot mix Exists expression with keyword arguments to When

2020-05-19 Thread Django
#31606: Cannot mix Exists expression with keyword arguments to When
-+-
 Reporter:  rheard   |Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Uncategorized|  Version:  3.0
 Severity:  Normal   |   Resolution:
 Keywords:   | Triage Stage:
 |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Description changed by rheard:

Old description:

> I don't seem to be able to provide an Exists expression to When alongside
> keyword arguments like you can with filter. For instance, consider:
>
> {{{
> class State(models.Model):
>  pass
>
> class County(models.Model):
>   name = CharField(max_length=50)
>   state = ForeignKey(State, related_name='counties')
> }}}
>
> I can execute the following query just fine:
>
> {{{
> County.objects.filter(
>   Exists(State.objects.filter(counties=OuterRef('pk'), name="Texas")),
>   name="Dallas",
> )
> }}}
>
> But a similar query using When does not work:
>
> {{{
> >>> County.objects.annotate(
>   status=Case(
> When(Exists(State.objects.filter(counties=OuterRef('pk'),
> name="Texas")), name="Dallas", then=Value("DALLAS COUNTY")),
> default=Value("ELSEWHERE"),
> ))
> }}}
>
> Instead the arguments must be wrapped in a Q object:
>
> {{{
> >>> County.objects.annotate(
>   status=Case(
> When(Q(Exists(State.objects.filter(counties=OuterRef('pk'),
> name="Texas")), name="Dallas"), then=Value("DALLAS COUNTY")),
> default=Value("ELSEWHERE"),
> ))
> }}}
>
> This is inconvenient and inconsistent with how filter works, as shown.
>
> When's __init__ method can be modified to allow similar input as filter.
> [https://github.com/rheard/django/commit/978e796bb18414d995d515ab7923831149300977
> Code is in a branch in my repo], but as this is my first time
> contributing to Django, I want to make sure I open a ticket and get
> feedback first.

New description:

 I don't seem to be able to provide an Exists expression to When alongside
 keyword arguments like you can with filter. For instance, consider:

 {{{
 class State(models.Model):
  pass

 class County(models.Model):
   name = CharField(max_length=50)
   state = ForeignKey(State, related_name='counties')
 }}}

 I can execute the following query just fine:

 {{{
 County.objects.filter(
   Exists(State.objects.filter(counties=OuterRef('pk'), name="Texas")),
   name="Dallas",
 )
 }}}

 But a similar query using When does not work:

 {{{
 >>> County.objects.annotate(
   status=Case(
 When(Exists(State.objects.filter(counties=OuterRef('pk'),
 name="Texas")), name="Dallas", then=Value("DALLAS COUNTY")),
 default=Value("ELSEWHERE"),
 ))
 TypeError: When() supports a Q object, a boolean expression, or lookups as
 a condition.
 }}}

 Instead the arguments must be wrapped in a Q object:

 {{{
 >>> County.objects.annotate(
   status=Case(
 When(Q(Exists(State.objects.filter(counties=OuterRef('pk'),
 name="Texas")), name="Dallas"), then=Value("DALLAS COUNTY")),
 default=Value("ELSEWHERE"),
 ))
 }}}

 This is inconvenient and inconsistent with how filter works, as shown.

 When's __init__ method can be modified to allow similar input as filter.
 
[https://github.com/rheard/django/commit/978e796bb18414d995d515ab7923831149300977
 Code is in a branch in my repo], but as this is my first time contributing
 to Django, I want to make sure I open a ticket and get feedback first.

--

-- 
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/064.5bc5e143e06cc71dc50509a305f563b8%40djangoproject.com.