#29643: Hashing list in Q objects when using __in lookup
-------------------------------------+-------------------------------------
Reporter: rhyre | Owner: nobody
Type: Uncategorized | Status: new
Component: Utilities | Version: 2.0
Severity: Normal | Resolution:
Keywords: hash, tuple, list, | Triage Stage:
drf | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by rhyre):
{{{
Model.objects.prefetch_related('types').exclude(status=1).annotate(
category=Case(
When(Q(status__in=[1,2,3]) & Q(id__in=[1,2,3]),
then=Value(2)),
default=Value(1),
output_field=IntegerField()
)
).only('category')
}}}
then it is used in viewsets.ReadOnlyModelViewSet of rest framework in
get_queryset.
When using
{{{
When(status__in=[1,2,3], id__in=[1,2,3], then=Value(2)),
}}}
everything works fine. Also when using Q with tuple as:
{{{
When(Q(status__in=(1,2,3)) & Q(id__in=(1,2,3)), then=Value(2)),
}}}
its ok.
Only with list it will crash. I've workarounded this to not use Q but it
wasn't a problem before.
--
Ticket URL: <https://code.djangoproject.com/ticket/29643#comment:3>
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/063.829376c04a0318cb145bc5e1dd4b8bb1%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.