Skip to content

Conversation

@misdoro
Copy link

@misdoro misdoro commented May 5, 2025

When an sql string is fed to to_tsquery, postgres functions get executed prior to string conversion to tsquery.

unaccent function may create unexpected single quote symbols, that will lead to "invalid tsquery" error from Postgres.

Wrap the unaccent output in regexp_replace, to make sure the query term is properly sanitized post normalization.

Related to #487 #558

misdoro added 2 commits April 28, 2025 18:19
The full list can be seen in `/usr/share/postgresql/tsearch_data/unaccent.rules` from Postgres
SQL unaccent may introduce single quotes from different unicode amended formatted characters,
We need to re-sanitize the string after we executed unaccent.
@misdoro
Copy link
Author

misdoro commented May 5, 2025

Hi @nertzy , what do you think of those changes?

I've extended the tests to add a few more characters that unaccent maps to single quote.

@nertzy nertzy self-assigned this Oct 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants