[Sqlalchemy-tickets] Issue #3160: postgresql - to_tsquery docs and implementation detail (zzzeek/sq
Brought to you by:
zzzeek
|
From: jvanasco <iss...@bi...> - 2014-08-07 22:03:39
|
New issue 3160: postgresql - to_tsquery docs and implementation detail https://bitbucket.org/zzzeek/sqlalchemy/issue/3160/postgresql-to_tsquery-docs-and jvanasco: I recently realized some implementation details of `to_tsquery` that are incompatible with the docs I drafted and how sqlalchemy integrates it. Not sure how to handle this. I based the docs/examples on existing tests and text. So we have this as the first bit of "Full Text Search" ( http://docs.sqlalchemy.org/en/latest/dialects/postgresql.html#full-text-search ) select([sometable.c.text.match("search string")]) SELECT text @@ to_tsquery('search string') FROM table well, if we put this into psql... badsql=> select to_tsquery('search string') ; ERROR: syntax error in tsquery: "search string" that's because tsquery has a rigid enforcement of input. text must either be tokenized and joined with acceptable operators : select to_tsquery('cat & rat'); be quoted : select to_tsquery('''search string'''); or use the alternate function select plainto_tsquery('search string'); So, these are acceptable: select to_tsquery('search & string'); select to_tsquery('''search string'''); select plainto_tsquery('search string'); but this is not: select to_tsquery('search string'); I'm not sure the best way to handle this nuance in the docs. |