Skip to content

Commit f2ea829

Browse files
committed
extend rather than append
1 parent 23631f6 commit f2ea829

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

django_mongodb_backend/query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def get_pipeline(self):
8989
for query in self.subqueries or ():
9090
pipeline.extend(query.get_pipeline())
9191
if self.match_mql:
92-
pipeline.append(QueryOptimizer().optimize(self.match_mql))
92+
pipeline.extend(QueryOptimizer().convert_expr_to_match(self.match_mql))
9393
if self.aggregation_pipeline:
9494
pipeline.extend(self.aggregation_pipeline)
9595
if self.project_fields:

django_mongodb_backend/query_conversion/expression_converters.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class _BaseExpressionConverter:
88
"""
99

1010
@classmethod
11-
def optimize(cls, expr):
11+
def convert(cls, expr):
1212
raise NotImplementedError("Subclasses should implement this method.")
1313

1414
@classmethod
@@ -38,7 +38,7 @@ class _EqExpressionConverter(_BaseExpressionConverter):
3838
"""Convert $eq operation to a $match compatible query."""
3939

4040
@classmethod
41-
def optimize(cls, eq_args):
41+
def convert(cls, eq_args):
4242
if isinstance(eq_args, list) and len(eq_args) == 2:
4343
field_expr, value = eq_args
4444

@@ -58,7 +58,7 @@ class _InExpressionConverter(_BaseExpressionConverter):
5858
"""Convert $in operation to a $match compatible query."""
5959

6060
@classmethod
61-
def optimize(cls, in_args):
61+
def convert(cls, in_args):
6262
if isinstance(in_args, list) and len(in_args) == 2:
6363
field_expr, values = in_args
6464

@@ -77,7 +77,7 @@ class _LogicalExpressionConverter(_BaseExpressionConverter):
7777
"""Generic for converting logical operations to a $match compatible query."""
7878

7979
@classmethod
80-
def optimize(cls, combined_conditions):
80+
def convert(cls, combined_conditions):
8181
if isinstance(combined_conditions, list):
8282
optimized_conditions = []
8383
for condition in combined_conditions:
@@ -125,5 +125,5 @@ def convert_expression(expr):
125125
if isinstance(expr, dict) and len(expr) == 1:
126126
op = next(iter(expr.keys()))
127127
if op in OPTIMIZABLE_OPS:
128-
return OPTIMIZABLE_OPS[op].optimize(expr[op])
128+
return OPTIMIZABLE_OPS[op].convert(expr[op])
129129
return None

0 commit comments

Comments
 (0)