diff --git a/taiga/base/utils/db.py b/taiga/base/utils/db.py index b3ff07a7..f9fd4b9d 100644 --- a/taiga/base/utils/db.py +++ b/taiga/base/utils/db.py @@ -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: diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 008877e0..483f2528 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -108,6 +108,9 @@ TS_QUERY_TRANSFORMATIONS = [ ("(1)", "( 1 )"), ("1((", "1"), ("test\\", "'test':*"), + ('"', "'\"':*"), + ('""', "'\"\"':*"), + ('"""', "'\"\"':* & '\"':*"), ] def test_to_tsquery(): for (input, expected) in TS_QUERY_TRANSFORMATIONS: