#27732: django.contrib.postgres.search SearchRank doesn't handle
SearchVectorField
references
----------------------------------+--------------------------------------
Reporter: Matt Hoskins | Owner: (none)
Type: Bug | Status: new
Component: contrib.postgres | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------+--------------------------------------
Comment (by Matt Hoskins):
The example for SearchRank in the documentation does only shows passing in
a SearchVector() as the first argument to SearchRank and a SearchQuery()
for the second so I was a little surprised when looking at the code to
find it was behaving such that if you passed in a string for the first
argument that it assumed you'd just missed off wrapping it in a
SearchVector() rather than it potentially being a reference to a
SearchVectorField.
If SearchRank were left as is (i.e. not supporting passing in a string
which references a SearchVectorField) then I think it would be useful for
the documentation for SearchVectorField to set out the F() "work around"
as the way to use a SearchVectorField in SearchRank. E.g. just have a bit
saying "To use a SearchVectorField in SearchRank then do..." and given an
example too. It takes a little bit of figuring out otherwise (particularly
as the documentation makes no mention that you can pass in a string as the
first argument and it'll wrap it in a SearchVector for you) and I have to
admit wrapping it in F() to prevent that behaviour is not a leap I'd made
yet as most database functions in django just take field references as
strings if the type of the field is already suitable.
--
Ticket URL: <https://code.djangoproject.com/ticket/27732#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 post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/070.e7300ff590949ff53ac886b03e656efd%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.