Changes between Initial Version and Version 4 of Ticket #31496


Ignore:
Timestamp:
Oct 6, 2020, 5:29:02 AM (4 years ago)
Author:
David Wobrock
Comment:

Hi,

Suggested patch: https://github.com/django/django/pull/13503 which probably needs some improvements here and there to be more concise and sustainable :)

Thanks! David

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #31496

    • Property Triage Stage UnreviewedAccepted
    • Property Summary When using 'annotate', 'union', 'order_by('annotate_field')' and 'values' at the same time, error occurredCombined queryset crash when chaining `values()` after `order_by()` with annotated constants.
    • Property Cc Hasan Ramezani David Wobrock added
    • Property Has patch set
    • Property Owner changed from nobody to David Wobrock
    • Property Status newassigned
  • Ticket #31496 – Description

    initial v4  
    1 When i tried query with 'annotate', 'union', 'order_by('annotate_field')' and 'values' at the same time, i got AttributeError('NoneType' object has no attribute 'split')
     1When I tried query with 'annotate', 'union', 'order_by('annotate_field')' and 'values' at the same time, i got AttributeError('NoneType' object has no attribute 'split')
    22
    33ex)
    4 # 1. make 2 query_set
     4# 1. make 2 QuerySets
     5{{{
    56qs1 = Foo.objects.annotate(bar_val=Value(1, output_field=IntegerField())).filter(bar=False)
    67qs2 = Foo.objects.annotate(bar_val=Value(2, output_field=IntegerField())).filter(bar=True)
     8}}}
     9
    710
    811# 2. union
    9 qs3 = q1.union(q2)
     12{{{
     13qs3 = qs1.union(qs2)
     14}}}
    1015
    1116# 3. order_by annotate field
    12 qs4 = q3.order_by('bar_val')
     17{{{
     18qs4 = qs3.order_by('bar_val')
     19}}}
    1320
    1421# 4. get values
    15 q4.values('id')
     22{{{
     23qs4.values('id')
     24}}}
    1625
    1726In this case, I confirmed ('id', None) tuple passed by compiler.query.set_values() in django/db/models/sql/compiler.py
Back to Top