From 4ea2262400c8f311b2b9f3e4bcc13d1dfc99aed2 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Mon, 4 Jan 2016 10:58:50 +0100 Subject: [PATCH] Issue #3492: Search fails if using quotating marks --- taiga/base/utils/db.py | 3 ++- tests/unit/test_utils.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) 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: