PostgreSQL fulltext search broken when query string is not in proper tsquery format

Issue #3286 duplicate
Priit Laes created an issue

Postgres full text search with query strings that are not in proper format fails. Example from documentation:

Following SQLAlchemy code (taken from "Full Text Search" section under PostgreSQL dialect docs):

select([sometable.c.text.match("search string")])

should emit following SQL:

SELECT text @@ to_tsquery('search string') FROM table

But when executing that (using real column name and table name) ends up with:

ERROR: syntax error in tsquery: "search string"

There's plainto_tsquery function that should be used instead, when query string is not in proper format: SELECT text @@ plainto_tsquery('search string') FROM table

My idea would be to use plainto_tsquery with column.match and introduce column.match_tsquery which ends up emitting to_tsquery SQL.

Comments (1)

  1. Log in to comment