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

Fixes an issue with full text search compatibility and Django 3.2 #3516

Merged
merged 1 commit into from
May 3, 2023
Merged
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
13 changes: 11 additions & 2 deletions src/core/model_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,14 +513,23 @@ def mysql_search(self, search_term, search_filters, sort=None, site=None):
def get_search_lookups(self):
return self.search_lookups


class SearchVector(DjangoSearchVector):
""" An Extension of SearchVector that works with SearchVectorField

Django's implementation assumes that the `to_tsvector` function needs
to be called with the provided column, except that when the field is already
a SearchVectorField, there is no need.
a SearchVectorField, there is no need. Django's implementation in 2.2
(405c8363362063542e9e79beac53c8437d389520) also attempts to cast the
column data into a TextField, prior to casting to the tsvector, which we
override under `set_source_expressions`

"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is also in #3515

def set_source_expressions(self, _):
""" Ignore Django's implementation
We don't require the expressions to be re-casted during the as_sql call
"""
pass

# Override template to ignore function
function = None
template = '%(expressions)s'