Gregor Jerše
unread,Apr 16, 2014, 3:16:02 PM4/16/14Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to django...@googlegroups.com
Hi!
I am experiencing a weird Queryset behavior. Let the variable treatments refer
to an ordered (and sliced) queryset. The first query
Service.objects.filter(treatment__in=treatments).distinct()
returns different objects than the second one
Service.objects.filter(treatment__in=list(treatments)).distinct()
, but I would expect both results to be the same. Service model declares
treatment field as ForeignKey.
The results given by the first query are incorrect. Further SQL code
inspection reveals that ORDER BY clause (from treatments QuerySet) is missing
in subselect.
The results of the second query are correct, since subquery is evaluated first
(with ORDER BY clause included).
It actually looks similar to an old bug #12328, which was marked as fixed long
time ago and I am using Django 1.6. Am I missing something?
Many Thanks,
Gregor