#28900: QuerySet.values() and values_list() for compound queries fails with
annotation.
-------------------------------------+-------------------------------------
     Reporter:  elliott-omosheye     |                    Owner:  ontowhee
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  1.11
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  union, values        |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by ontowhee):

 Replying to [comment:10 David Sanders]:

 Thanks for the simple example!

 I'm not too knowledgeable about the ORM, but I'm trying to work through
 this problem. Is the problem within annotate, or somewhere else, or a
 combination of annotate and something else?

 Using the simple example, I tried taking the union of Foo and Bar without
 any annotation, and I apply `.values('name')` to the result


 {{{
 Foo.objects.create(name='hello')
 Bar.objects.create(name='goodbye')

 qs = Foo.objects.all().union(Bar.objects.all())
 print(qs)
 }}}

 and it gives

 {{{
 <QuerySet [{'name': 'goodbye'}, {'name': 'hello'}]>
 }}}

 Which is correct and expected. However, when I remove `.values('name')`

 {{{
 qs = Foo.objects.all().union(Bar.objects.all())
 print(qs)
 }}}

 it then gives

 {{{
 <QuerySet [<Foo: Foo object (1)>, <Foo: Foo object (1)>]>
 }}}

 Is this expected, or is this something to look into?
-- 
Ticket URL: <https://code.djangoproject.com/ticket/28900#comment:15>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018efc527c8b-b9b4991f-081d-49d0-ac71-1392515e8086-000000%40eu-central-1.amazonses.com.

Reply via email to