Skip to content

Commit 8331701

Browse files
committed
fixed path name reconcilitation issue on in JSONField tests
1 parent 00426a7 commit 8331701

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

django_mongodb_backend/query_conversion/expression_converters.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def convert(cls, expr):
66
raise NotImplementedError("Subclasses must implement this method.")
77

88
@classmethod
9-
def is_simple_field_name(cls, field_name):
9+
def is_simple_path_name(cls, field_name):
1010
return (
1111
isinstance(field_name, str)
1212
and field_name != ""
@@ -29,19 +29,19 @@ def is_simple_get_field(cls, get_field_object):
2929
):
3030
input_expr = get_field_expr["input"]
3131
field_name = get_field_expr["field"]
32-
return cls.convert_field_name(input_expr) and (
33-
isinstance(field_name, str) and not field_name.startswith("$")
32+
return cls.convert_path_name(input_expr) and (
33+
isinstance(field_name, str) and "$" not in field_name and "." not in field_name
3434
)
3535
return False
3636

3737
@classmethod
38-
def convert_field_name(cls, field_name):
39-
if cls.is_simple_field_name(field_name):
38+
def convert_path_name(cls, field_name):
39+
if cls.is_simple_path_name(field_name):
4040
return field_name[1:]
4141
if cls.is_simple_get_field(field_name):
4242
get_field_input = field_name["$getField"]["input"]
43-
get_field_field = field_name["$getField"]["field"]
44-
return f"{cls.convert_field_name(get_field_input)}.{get_field_field}"
43+
get_field_field_name = field_name["$getField"]["field"]
44+
return f"{cls.convert_path_name(get_field_input)}.{get_field_field_name}"
4545
return None
4646

4747
@classmethod
@@ -75,7 +75,7 @@ def convert(cls, args):
7575
if isinstance(args, list) and len(args) == 2:
7676
field_expr, value = args
7777
# Check if first argument is a simple field reference.
78-
if (field_name := cls.convert_field_name(field_expr)) and cls.is_simple_value(value):
78+
if (field_name := cls.convert_path_name(field_expr)) and cls.is_simple_value(value):
7979
if cls.operator == "$eq":
8080
return {field_name: value}
8181
return {field_name: {cls.operator: value}}

0 commit comments

Comments
 (0)