nearform/udaru

tsquery characters

Closed this issue · 1 comments

we have issue with team names having characters that need escaping prior to input e.g. : is reserved to qualify parts of the search with weightings, substring search and so on...

proposing this solution...

query.replace(/'/g, "''").replace(/\\/g, '\\\\').split(' ').join("':* & '") + "':*"

basically encapsulating each component part of string with quotes (this handles characters like : which are reserved) and then anding together, then escaping quotes within each string and backslashes...

looks a bit messy

I want to put this in utils and use it centrally for each search tsquery...

posting here before PRing

@dberesford @mihaidma

pr approved