@@ -8,7 +8,7 @@ class _BaseExpressionConverter:
8
8
"""
9
9
10
10
@classmethod
11
- def optimize (cls , expr ):
11
+ def convert (cls , expr ):
12
12
raise NotImplementedError ("Subclasses should implement this method." )
13
13
14
14
@classmethod
@@ -38,7 +38,7 @@ class _EqExpressionConverter(_BaseExpressionConverter):
38
38
"""Convert $eq operation to a $match compatible query."""
39
39
40
40
@classmethod
41
- def optimize (cls , eq_args ):
41
+ def convert (cls , eq_args ):
42
42
if isinstance (eq_args , list ) and len (eq_args ) == 2 :
43
43
field_expr , value = eq_args
44
44
@@ -58,7 +58,7 @@ class _InExpressionConverter(_BaseExpressionConverter):
58
58
"""Convert $in operation to a $match compatible query."""
59
59
60
60
@classmethod
61
- def optimize (cls , in_args ):
61
+ def convert (cls , in_args ):
62
62
if isinstance (in_args , list ) and len (in_args ) == 2 :
63
63
field_expr , values = in_args
64
64
@@ -77,7 +77,7 @@ class _LogicalExpressionConverter(_BaseExpressionConverter):
77
77
"""Generic for converting logical operations to a $match compatible query."""
78
78
79
79
@classmethod
80
- def optimize (cls , combined_conditions ):
80
+ def convert (cls , combined_conditions ):
81
81
if isinstance (combined_conditions , list ):
82
82
optimized_conditions = []
83
83
for condition in combined_conditions :
@@ -125,5 +125,5 @@ def convert_expression(expr):
125
125
if isinstance (expr , dict ) and len (expr ) == 1 :
126
126
op = next (iter (expr .keys ()))
127
127
if op in OPTIMIZABLE_OPS :
128
- return OPTIMIZABLE_OPS [op ].optimize (expr [op ])
128
+ return OPTIMIZABLE_OPS [op ].convert (expr [op ])
129
129
return None
0 commit comments