Possible bug when filter per month on a variable generated by annotate

38 views
Skip to first unread message

Paulo Maciel

unread,
Sep 7, 2015, 9:07:10 PM9/7/15
to Django developers (Contributions to Django itself)
Possible bug when filter per __month on a variable generated by annotate

p = Person.objects.annotate(
    main_date
=Case(
       
When(ok=True, then='date_a'),
       
default=F('date_b'),
        output_field
=DateField()
   
)
)
a
= p.filter(main_date__month=9)
print(a)


IndexError at /

tuple index out of range

Traceback:
File "/Users/zzzzz/.virtualenvs/dddd/lib/python3.4/site-packages/django/core/handlers/base.py" in get_response
 
132.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/zzzzz/projects/myapp/views.py" in persons
 
42.     print(a):
File "/Users/zzzzz/.virtualenvs/dddd/lib/python3.4/site-packages/django/db/models/query.py" in __iter__
 
162.         self._fetch_all()
File "/Users/zzzzz/.virtualenvs/dddd/lib/python3.4/site-packages/django/db/models/query.py" in _fetch_all
 
965.             self._result_cache = list(self.iterator())
File "/Users/zzzzz/.virtualenvs/dddd/lib/python3.4/site-packages/django/db/models/query.py" in iterator
 
238.         results = compiler.execute_sql()
File "/Users/zzzzz/.virtualenvs/dddd/lib/python3.4/site-packages/django/db/models/sql/compiler.py" in execute_sql
 
840.             cursor.execute(sql, params)
File "/Users/zzzzz/.virtualenvs/dddd/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
 
79.             return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/zzzzz/.virtualenvs/dddd/lib/python3.4/site-packages/django/db/backends/utils.py" in execute
 
64.                 return self.cursor.execute(sql, params)


Exception Type: IndexError at /
Exception Value: tuple index out of range

but when I use __range works
Reply all
Reply to author
Forward
0 new messages