#31304: PostgreSQL full-text search employs coalesce function for non-null
single-
column searches with SearchVector
-------------------------------------+-------------------------------------
Reporter: Paul Boddie | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 2.2
(models, ORM) |
Severity: Normal | Resolution:
Keywords: PostgreSQL text | Triage Stage:
search FTS coalesce SearchVector | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Simon Charette):
I guess this ticket could also re-purposed as a new feature to make
`__search=SearchQuery` force the usage of the rhs's `config` for the lhs.
Something along
{{{#!diff
diff --git a/django/contrib/postgres/lookups.py
b/django/contrib/postgres/lookups.py
index cc5bc022c6..1cb03b9510 100644
--- a/django/contrib/postgres/lookups.py
+++ b/django/contrib/postgres/lookups.py
@@ -1,7 +1,9 @@
from django.db.models import Lookup, Transform
from django.db.models.lookups import Exact, FieldGetDbPrepValueMixin
-from .search import SearchVector, SearchVectorExact, SearchVectorField
+from .search import (
+ SearchQuery, SearchVector, SearchVectorExact, SearchVectorField
+)
class PostgresSimpleLookup(FieldGetDbPrepValueMixin, Lookup):
@@ -57,7 +59,10 @@ class SearchLookup(SearchVectorExact):
def process_lhs(self, qn, connection):
if not isinstance(self.lhs.output_field, SearchVectorField):
- self.lhs = SearchVector(self.lhs)
+ config = None
+ if isinstance(self.rhs, SearchQuery):
+ config = self.rhs.config
+ self.lhs = SearchVector(self.lhs, config=config)
lhs, lhs_params = super().process_lhs(qn, connection)
return lhs, lhs_params
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/31304#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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.9828f740356ba69ff38867e0546ab147%40djangoproject.com.