I have a computed column that is a tsvector
.
The api sends a search query, but, of course, these are not valid tsvector
s. Postgres's plainto_tsquery
converts text input to a correctly formatted tsvector
for matching.
This breaks with SQLAlchemy.
column.match(func.plainto_tsquery('english', search))
does not work because SQLAlchemy converts that to:
column @@ to_tsquery(plainto_tsquery('english', 'the search query'))
what I actually want is the correct operator (@@
) but without the magic conversion
column @@ plainto_tsquery('english', 'the search query')
A dumb way that works but is not what I want is:
column.match(
cast(func.plainto_tsquery('english', search), String)
)
How about
column.op("@@")(func.plainto_tsquery('english', search))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With