Re: [Django] #29166: in lookup doesn't work with lists in a When clause

2018-03-02 Thread Django
#29166: in lookup doesn't work with lists in a When clause
-+-
 Reporter:  Matthew Pava |Owner:  felixxm
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  2.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:  fixed
 Keywords:  lookup in| Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Дилян Палаузов):

 * cc: Дилян Палаузов (added)


-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.14518ef80b93ea789e34499a05b84a9e%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29166: in lookup doesn't work with lists in a When clause

2018-03-02 Thread Django
#29166: in lookup doesn't work with lists in a When clause
-+-
 Reporter:  Matthew Pava |Owner:  felixxm
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  2.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:  fixed
 Keywords:  lookup in| Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Дилян Палаузов):

 {{{
 diff --git a/django/db/models/expressions.py
 b/django/db/models/expressions.py
 +return hash((path, output_field) + args + tuple([
 +(key, tuple(value)) if isinstance(value, list) else (key,
 value)
 +for key, value in kwargs.items()
 +]))
 }}}

 Aren't here the {{{[}}} and {{{]}}} superflous, as the parameter of both
 {{{tuple()}}} and {{{[]}}} have to be iterable, and this the type of the
 inlined {{{for}}}:
 {{{
 >>> tuple([(x,y) for x, y in {'a': 1, 'b':2, 'c':3}.items()])
 (('a', 1), ('b', 2), ('c', 3))
 >>> tuple((x,y) for x, y in {'a': 1, 'b':2, 'c':3}.items())
 (('a', 1), ('b', 2), ('c', 3))
 }}}

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.5b9e7207ba2b0de0c5df779b0e99103b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29166: in lookup doesn't work with lists in a When clause

2018-02-28 Thread Django
#29166: in lookup doesn't work with lists in a When clause
-+-
 Reporter:  Matthew Pava |Owner:  felixxm
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  2.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:  fixed
 Keywords:  lookup in| Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Mariusz Felisiak ):

 In [changeset:"10a20e4b37da94fd55b4e9a13e634c2a379bd9e0" 10a20e4]:
 {{{
 #!CommitTicketReference repository=""
 revision="10a20e4b37da94fd55b4e9a13e634c2a379bd9e0"
 [2.0.x] Fixed #29166 -- Fixed crash in When() expression with a list
 argument.

 Thanks Matthew Pava for the report and Tim Graham and Carlton Gibson for
 reviews.
 Regression in 19b2dfd1bfe7fd716dd3d8bfa5f972070d83b42f.

 Backport of 54f80430be4a9adf1fc00b4ca17547415fafc69b from master
 }}}

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.dc456bcb54a355f7369be9e3b73e93b2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29166: in lookup doesn't work with lists in a When clause

2018-02-28 Thread Django
#29166: in lookup doesn't work with lists in a When clause
-+-
 Reporter:  Matthew Pava |Owner:  felixxm
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  2.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:  fixed
 Keywords:  lookup in| Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by GitHub ):

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


Comment:

 In [changeset:"54f80430be4a9adf1fc00b4ca17547415fafc69b" 54f8043]:
 {{{
 #!CommitTicketReference repository=""
 revision="54f80430be4a9adf1fc00b4ca17547415fafc69b"
 Fixed #29166 -- Fixed crash in When() expression with a list argument.

 Thanks Matthew Pava for the report and Tim Graham and Carlton Gibson for
 reviews.
 Regression in 19b2dfd1bfe7fd716dd3d8bfa5f972070d83b42f.
 }}}

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.0b2db6e1232f44c00ef2f3b26f4f522f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29166: in lookup doesn't work with lists in a When clause

2018-02-28 Thread Django
#29166: in lookup doesn't work with lists in a When clause
-+-
 Reporter:  Matthew Pava |Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  2.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:  lookup in| Triage Stage:  Ready for
 |  checkin
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Carlton Gibson):

 * 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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.2fecdfe761c3e00caa6638588827417a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29166: in lookup doesn't work with lists in a When clause

2018-02-27 Thread Django
#29166: in lookup doesn't work with lists in a When clause
-+-
 Reporter:  Matthew Pava |Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  2.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:  lookup in| Triage Stage:  Accepted
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/9734 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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.e52a0c9f626c7e6220aad751ef20a706%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29166: in lookup doesn't work with lists in a When clause

2018-02-27 Thread Django
#29166: in lookup doesn't work with lists in a When clause
-+-
 Reporter:  Matthew Pava |Owner:  felixxm
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  2.0
  (models, ORM)  |
 Severity:  Release blocker  |   Resolution:
 Keywords:  lookup in| Triage Stage:  Accepted
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by felixxm):

 * status:  new => assigned
 * owner:  nobody => felixxm
 * severity:  Normal => Release blocker
 * stage:  Unreviewed => Accepted


Comment:

 Regression in 19b2dfd1bfe7fd716dd3d8bfa5f972070d83b42f.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.a6bd2c7c4b9cf7ed59cc8afc628ab422%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #29166: in lookup doesn't work with lists in a When clause

2018-02-27 Thread Django
#29166: in lookup doesn't work with lists in a When clause
-+-
 Reporter:  Matthew Pava |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  2.0
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  lookup in| Triage Stage:
 |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Description changed by Matthew Pava:

Old description:

> I have an annotation that worked fine in Django 1.11, but I just
> discovered that it doesn't work with Django 2.0.  The error message
> reported:
> `TypeError: unhashable type: 'list'`
>
> I have an `Order` model that has a `status` and `status_date` field, and
> here's the query that worked in the past (simplified):
>
> {{{
> Order.objects.annotate(
> end_date=Case(
> When(
> status__in=[3, 2],
> then=Cast(F('status_date'), DateField())
> ),
> default=Value(timezone.now().date())
> )
> )
> }}}
>
> Note the list used as the arg in the `__in` lookup.
>
> My current workaround is to use `Q` objects with the `|` operator.
> {{{
> Order.objects.annotate(
> end_date=Case(
> When(
> Q(status=3) | Q(status=2),
> then=Cast(F('status_date'), DateField())
> ),
> default=Value(timezone.now().date())
> )
> )
> }}}
>
> Others may not find that workaround as practical.

New description:

 I have an annotation that worked fine in Django 1.11, but I just
 discovered that it doesn't work with Django 2.0.  The error message
 reported:
 `TypeError: unhashable type: 'list'`

 I have an `Order` model that has a `status` and `status_date` field, and
 here's the query that worked in the past (simplified):

 {{{
 Order.objects.annotate(
 end_date=Case(
 When(
 status__in=[3, 2],
 then=Cast(F('status_date'), DateField())
 ),
 default=Value(timezone.now().date())
 )
 )
 }}}

 Note the list used as the arg in the `__in` lookup.

 My current workaround is to use `Q` objects with the `|` operator.
 {{{
 Order.objects.annotate(
 end_date=Case(
 When(
 Q(status=3) | Q(status=2),
 then=Cast(F('status_date'), DateField())
 ),
 default=Value(timezone.now().date())
 )
 )
 }}}

 Others may not find that workaround as practical.
 I have also not verified this issue in other `Expression`s in the ORM.

--

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.c9b3904d8ff9d65ea4efbfaa851b5472%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #29166: in lookup doesn't work with lists in a When clause

2018-02-27 Thread Django
#29166: in lookup doesn't work with lists in a When clause
-+-
   Reporter:  Matthew|  Owner:  nobody
  Pava   |
   Type:  Bug| Status:  new
  Component:  Database   |Version:  2.0
  layer (models, ORM)|
   Severity:  Normal |   Keywords:  lookup in
   Triage Stage: |  Has patch:  0
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  0
  UI/UX:  0  |
-+-
 I have an annotation that worked fine in Django 1.11, but I just
 discovered that it doesn't work with Django 2.0.  The error message
 reported:
 `TypeError: unhashable type: 'list'`

 I have an `Order` model that has a `status` and `status_date` field, and
 here's the query that worked in the past (simplified):

 {{{
 Order.objects.annotate(
 end_date=Case(
 When(
 status__in=[3, 2],
 then=Cast(F('status_date'), DateField())
 ),
 default=Value(timezone.now().date())
 )
 )
 }}}

 Note the list used as the arg in the `__in` lookup.

 My current workaround is to use `Q` objects with the `|` operator.
 {{{
 Order.objects.annotate(
 end_date=Case(
 When(
 Q(status=3) | Q(status=2),
 then=Cast(F('status_date'), DateField())
 ),
 default=Value(timezone.now().date())
 )
 )
 }}}

 Others may not find that workaround as practical.

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.0679623894f07af3e5b0748020aadcf6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.