Merge pull request #558 from taigaio/issue-3492-search-fails-when-using-quotation-marks

Issue #3492: Search fails if using quotating marks
remotes/origin/logger
David Barragán Merino 2016-01-04 14:22:53 +01:00
commit a28b04a154
2 changed files with 5 additions and 1 deletions

View File

@ -208,10 +208,11 @@ def to_tsquery(term):
if not bit:
continue
if bit.startswith('"') and bit.endswith('"'):
if bit.startswith('"') and bit.endswith('"') and len(bit)>2:
res.append(bit.replace('"', "'"))
else:
res.append("'%s':*" %(bit.replace("'", ""), ))
res.append("&")
while res and res[-1] in magic_values:

View File

@ -108,6 +108,9 @@ TS_QUERY_TRANSFORMATIONS = [
("(1)", "( 1 )"),
("1((", "1"),
("test\\", "'test':*"),
('"', "'\"':*"),
('""', "'\"\"':*"),
('"""', "'\"\"':* & '\"':*"),
]
def test_to_tsquery():
for (input, expected) in TS_QUERY_TRANSFORMATIONS: