Issue #3492: Search fails if using quotating marks

remotes/origin/logger
Alejandro Alonso 2016-01-04 10:58:50 +01:00 committed by David Barragán Merino
parent b619248cfe
commit 4ea2262400
2 changed files with 5 additions and 1 deletions

View File

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

View File

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