From 3ba45b7c872f54dfcc411a52544a801dadaec6b5 Mon Sep 17 00:00:00 2001 From: Andrew Brookins Date: Mon, 20 Sep 2021 16:08:24 -0700 Subject: [PATCH] Fix negation queries --- redis_developer/orm/model.py | 6 +++--- tests/test_hash_model.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/redis_developer/orm/model.py b/redis_developer/orm/model.py index 9c3151c..4e92eea 100644 --- a/redis_developer/orm/model.py +++ b/redis_developer/orm/model.py @@ -174,7 +174,7 @@ class FindQuery: elif op is Operators.NE: # TODO: Is this enough or do we also need a clause for all values # ([-inf +inf]) from which we then subtract the undesirable value? - result += f"~(@{field_name}:[{value} {value}])" + result += f"-(@{field_name}:[{value} {value}])" elif op is Operators.GT: result += f"@{field_name}:[({value} +inf]" elif op is Operators.LT: @@ -187,13 +187,13 @@ class FindQuery: if op is Operators.EQ: result += f"@{field_name}:{{{value}}}" elif op is Operators.NE: - result += f"~(@{field_name}:{{{value}}})" + result += f"-(@{field_name}:{{{value}}})" elif op is Operators.IN: expanded_value = self.expand_tag_value(value) result += f"(@{field_name}:{{{expanded_value}}})" elif op is Operators.NOT_IN: expanded_value = self.expand_tag_value(value) - result += f"~(@{field_name}:{{{expanded_value}}})" + result += f"-(@{field_name}:{{{expanded_value}}})" return result diff --git a/tests/test_hash_model.py b/tests/test_hash_model.py index 92544aa..c1027f2 100644 --- a/tests/test_hash_model.py +++ b/tests/test_hash_model.py @@ -261,7 +261,7 @@ def test_schema(): another_float: float # TODO: Fix - assert Address.schema() == "ON HASH PREFIX 1 redis-developer:address: " \ + assert Address.schema() == "ON HASH PREFIX 1 redis-developer:tests.test_hash_model.Address: " \ "SCHEMA pk TAG a_string TAG a_full_text_string TAG " \ "a_full_text_string_fts TEXT an_integer NUMERIC SORTABLE " \ "a_float NUMERIC"