Commit 37095afa authored by Vincent Pelletier's avatar Vincent Pelletier

Move assertion closer to the case it protects.

When search_value contains 'type' key, it is checked to not contain
'operator', so there can be no collision there.
parent e6a94aab
...@@ -222,9 +222,6 @@ class SearchKey(object): ...@@ -222,9 +222,6 @@ class SearchKey(object):
default_logical_operator = 'or' default_logical_operator = 'or'
parsed = False parsed = False
if isinstance(search_value, dict): if isinstance(search_value, dict):
# comparison_operator parameter collides with dict's 'operator' key.
# Fail loudly.
assert comparison_operator is None
actual_value = search_value['query'] actual_value = search_value['query']
if search_value.get('key') not in (None, self.__class__.__name__): if search_value.get('key') not in (None, self.__class__.__name__):
LOG(self.__class__.__name__, 100, LOG(self.__class__.__name__, 100,
...@@ -234,6 +231,9 @@ class SearchKey(object): ...@@ -234,6 +231,9 @@ class SearchKey(object):
assert 'operator' not in search_value, search_value assert 'operator' not in search_value, search_value
assert 'range' not in search_value, search_value assert 'range' not in search_value, search_value
else: else:
# comparison_operator parameter collides with dict's 'operator' key.
# Fail loudly.
assert comparison_operator is None
value_operator = search_value.get('operator') value_operator = search_value.get('operator')
value_range = search_value.get('range') value_range = search_value.get('range')
if value_range is not None: if value_range is not None:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment