Fix #188: Get rid of the workaround for django's __in bug

Related bug: https://code.djangoproject.com/ticket/15145
This commit is contained in:
Unai Zalakain 2017-05-01 23:07:13 +02:00
parent f3c6de2809
commit ba2f9d1341

View file

@ -537,20 +537,9 @@ class SearchEngine(object):
object_id_int__in=queryset,
)
else:
live_ids = list(queryset)
if live_ids:
filter &= Q(
object_id__in=live_ids,
)
else:
# HACK: There is a bug in Django
# (https://code.djangoproject.com/ticket/15145)
# that messes up __in queries when the iterable is empty.
# This bit of nonsense ensures that this aspect of the query
# will be impossible to fulfill.
filter &= Q(
content_type=ContentType.objects.get_for_model(model).id + 1,
)
filter &= Q(
object_id__in=queryset,
)
# Add the model to the filter.
content_type = ContentType.objects.get_for_model(model)
filter &= Q(