From ba2f9d13416a70c6f3d96c4ec47c466d3e1f3001 Mon Sep 17 00:00:00 2001 From: Unai Zalakain Date: Mon, 1 May 2017 23:07:13 +0200 Subject: [PATCH] Fix #188: Get rid of the workaround for django's __in bug Related bug: https://code.djangoproject.com/ticket/15145 --- watson/search.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/watson/search.py b/watson/search.py index a040584..e51020f 100644 --- a/watson/search.py +++ b/watson/search.py @@ -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(