Re: [Django] #24420: Can't order_by annotated field if annotated field uses conditional expression

2015-03-05 Thread Django
#24420: Can't order_by annotated field if annotated field uses conditional
expression
-+-
 Reporter:  krisfields   |Owner:  jarshwah
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.8beta1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  order_by,| Triage Stage:  Ready for
  annotation, conditional|  checkin
  expression |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by Josh Smeaton ):

 In [changeset:"823f8cdbc91f85a8ab3cb1ccfec5659037b5c148"]:
 {{{
 #!CommitTicketReference repository=""
 revision="823f8cdbc91f85a8ab3cb1ccfec5659037b5c148"
 [1.8.x] Fixed #24420 -- Allowed ordering by case expressions

 Backport of ceaf31adfff3801f1092a215f73704e15a70e90c 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/068.9877484e996992cdca66a15228b596c5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24420: Can't order_by annotated field if annotated field uses conditional expression

2015-03-05 Thread Django
#24420: Can't order_by annotated field if annotated field uses conditional
expression
-+-
 Reporter:  krisfields   |Owner:  jarshwah
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.8beta1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  order_by,| Triage Stage:  Ready for
  annotation, conditional|  checkin
  expression |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by Josh Smeaton ):

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


Comment:

 In [changeset:"ceaf31adfff3801f1092a215f73704e15a70e90c"]:
 {{{
 #!CommitTicketReference repository=""
 revision="ceaf31adfff3801f1092a215f73704e15a70e90c"
 Fixed #24420 -- Allowed ordering by case expressions
 }}}

--
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/068.f917e7bfd0222340299d07494e5bfc61%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24420: Can't order_by annotated field if annotated field uses conditional expression

2015-03-05 Thread Django
#24420: Can't order_by annotated field if annotated field uses conditional
expression
-+-
 Reporter:  krisfields   |Owner:  jarshwah
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.8beta1
  (models, ORM)  |
 Severity:  Normal   |   Resolution:
 Keywords:  order_by,| Triage Stage:  Ready for
  annotation, conditional|  checkin
  expression |
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by timgraham):

 * has_patch:  0 => 1
 * component:  Uncategorized => Database layer (models, ORM)
 * stage:  Accepted => Ready for checkin


Comment:

 Seems like a candidate for backport.

--
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/068.074c929adbf49a06a39a12726a6fa0ad%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24420: Can't order_by annotated field if annotated field uses conditional expression

2015-03-04 Thread Django
#24420: Can't order_by annotated field if annotated field uses conditional
expression
-+-
 Reporter:  krisfields   |Owner:  jarshwah
 Type:  Bug  |   Status:  assigned
Component:  Uncategorized|  Version:  1.8beta1
 Severity:  Normal   |   Resolution:
 Keywords:  order_by,| Triage Stage:  Accepted
  annotation, conditional|
  expression |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-

Comment (by jarshwah):

 See: https://github.com/django/django/pull/4239

 Funnily enough, being explicit worked before this patch:

 CaseTestModel.objects.filter(integer__lte=2).annotate(test=Case(
 When(integer=1, then=2),
 When(integer=2, then=1),
 default=3,
 output_field=models.IntegerField(),
 )).order_by(F('test').asc())

 The problem is that the same instance of each `When` clause has
 resolve_expression called on it multiple times. Once for the annotation,
 and once again for the order_by. The problem is that
 When.resolve_expression converts the Q() into a WhereNode(), and
 overwrites the condition property. It's not idempotent.

--
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/068.5ff49c68fad4e3b399582669cb5499e5%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Django] #24420: Can't order_by annotated field if annotated field uses conditional expression

2015-02-26 Thread Django
#24420: Can't order_by annotated field if annotated field uses conditional
expression
-+-
 Reporter:  krisfields   |Owner:  jarshwah
 Type:  Bug  |   Status:  assigned
Component:  Uncategorized|  Version:  1.8beta1
 Severity:  Normal   |   Resolution:
 Keywords:  order_by,| Triage Stage:  Accepted
  annotation, conditional|
  expression |
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by jarshwah):

 * status:  new => assigned
 * needs_better_patch:   => 0
 * needs_tests:   => 0
 * owner:  nobody => jarshwah
 * needs_docs:   => 0
 * 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 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/068.973e425cf2e0daab00323007a1fa0cab%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.


[Django] #24420: Can't order_by annotated field if annotated field uses conditional expression

2015-02-26 Thread Django
#24420: Can't order_by annotated field if annotated field uses conditional
expression
-+-
 Reporter:   |  Owner:  nobody
  krisfields |
 Type:  Bug  | Status:  new
Component:   |Version:  1.8beta1
  Uncategorized  |   Keywords:  order_by, annotation, conditional
 Severity:  Normal   |  expression
 Triage Stage:   |  Has patch:  0
  Unreviewed |
Easy pickings:  0|  UI/UX:  0
-+-
 Continuing with the Client example on
 https://docs.djangoproject.com/en/dev/ref/models/conditional-expressions/


 {{{
 from django.db import models

 class Client(models.Model):
 REGULAR = 'R'
 GOLD = 'G'
 PLATINUM = 'P'
 ACCOUNT_TYPE_CHOICES = (
 (REGULAR, 'Regular'),
 (GOLD, 'Gold'),
 (PLATINUM, 'Platinum'),
 )
 name = models.CharField(max_length=50)
 registered_on = models.DateField()
 account_type = models.CharField(
 max_length=1,
 choices=ACCOUNT_TYPE_CHOICES,
 default=REGULAR,
 )

 Client.objects.annotate(
 discount=Case(
 When(account_type=Client.GOLD, then=Value('5%')),
 When(account_type=Client.PLATINUM, then=Value('10%')),
 default=Value('0%'),
 output_field=CharField(),
 ),
 ).order_by('discount')
 }}}

 Error is:

 {{{
 
 }}}

--
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/053.a8f77eeeac54e7ff6a7e412c767c4056%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.