Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#308 Use Django's Cast function #309

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions watson/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.core.signals import request_finished
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django.db import models, connections, router
from django.db.models import Q
from django.db.models import Q, TextField
from django.db.models.expressions import RawSQL
from django.db.models.functions import Cast
from django.db.models.query import QuerySet
Expand Down Expand Up @@ -565,10 +565,7 @@ def _create_model_filter(self, models, backend):
)
else:
queryset = queryset.annotate(
watson_pk_str=RawSQL(backend.do_string_cast(
connections[queryset.db],
model._meta.pk.db_column or model._meta.pk.attname,
), ()),
watson_pk_str=Cast('pk', TextField())
).values_list("watson_pk_str", flat=True)
filter &= Q(
object_id__in=queryset,
Expand Down