Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/solrq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class Value(object):
"""

# note: since we escape spaces there is no need to escape AND, OR, NOT
ESCAPE_RE = re.compile(r'(?<!\\)(?P<char>[ &|+\-!(){}[\]*^"~?:])')
ESCAPE_RE = re.compile(r'(?<!\\)(?P<char>[ &|+\\\-!(){}[\]*^"~?:])')
TIMEDELTA_FORMAT = "NOW{days:+d}DAYS{secs:+d}SECONDS{mills:+d}MILLISECONDS"

def __init__(self, raw, safe=False):
Expand Down
11 changes: 4 additions & 7 deletions tests/test_squery.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,19 +192,16 @@ def test_proximity():
# ... but not if marked as safe
assert str(Proximity("foo bar", 12, safe=True)) == '"foo bar"~12'

# note: boosting an explicit value has same result as raw string
assert str(
Proximity(Value("foo bar"), 12)
) == str(
Proximity(Value("foo bar", safe=True), 12)
) == '"foo\\ bar"~12'

# note: only marking safe on all stages ensures it will not be escaped
assert str(
Proximity(Value("foo bar", safe=True), 12, safe=True)
) == '"foo bar"~12'

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add additional new line to satisfy pep8 checks


def test_can_escape_special_characters():
assert str(Q(foo="\\")) == "foo:\\\\"


def test_reprs():
assert repr(Q(foo="bar"))
assert repr(Value("foobar"))