#25316: Can't use order_by and values(_list) together after annotating
----------------------------------------------+----------------------------
     Reporter:  adrian17                      |      Owner:  nobody
         Type:  Bug                           |     Status:  new
    Component:  Database layer (models, ORM)  |    Version:  1.8
     Severity:  Normal                        |   Keywords:  annotate,
                                              |  order_by
 Triage Stage:  Unreviewed                    |  Has patch:  0
Easy pickings:  0                             |      UI/UX:  0
----------------------------------------------+----------------------------
 Example:


 {{{
 # model

 from django.db import models
 class Table(models.Model):
     value = models.IntegerField()

 # tests

 from django.test import TestCase
 from testapp.models import Table
 from django.db.models import IntegerField, Case, Value, When
 class Test1(TestCase):
     def test_1(self):
         query = Table.objects.annotate(
             other=Case(
                 When(value=11, then=Value(1)),
                 output_field=IntegerField()
             ),
         ).order_by('other', 'value').values('id')

         print query

 }}}

 The error is:

 {{{
 AttributeError: 'WhereNode' object has no attribute 'resolve_expression'
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/25316>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.629ae800282d121a8b03a4a464c26952%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to